CHSwap is a decentralized token swap ecosystem built on the Celo blockchain, providing a seamless and transparent way to buy and sell CHP tokens using USDC.
It consists of two main parts — a smart contract backend and a web-based frontend.
CHSwap/
├── Contract/ # Solidity smart contracts (Hardhat)
└── Web/ # Frontend app (React + TypeScript + Wagmi)
Each module has its own README for detailed setup, but this document gives you a complete overview.
🗁 Location: /Contract
📄 Full Documentation: View Contract README →
The CHSwap contract handles all the token exchange logic between CHP and USDC, featuring:
- Buy and sell functions for CHP
- Configurable prices (
buyPricePer1000CHP_USDC,sellPricePer1000CHP_USDC) - Events for tracking on-chain swaps (
CHPBought,CHPSold) - Owner controls for deposit, withdraw, and price updates
1. Clone the repository
git clone https://github.com/critterholes/Swap.git
cd Swap/Contract2. Install dependencies
npm install3. Setup environment
Create a .env file inside the Contract folder:
PRIVATE_KEY=""
CHP_ADDRESS=""
USDC_ADDRESS=""
CELO_RPC_URL="https://forno.celo.org"
ETHERSCAN_API_KEY=""4. Compile & Deploy
npx hardhat compile
npx hardhat run scripts/deploy.js --network celo5. Verify Contract (optional)
npx hardhat verify --network celo <contract-address> "<chp-address>" "<usdc-address>"🗁 Location: /Web
📄 Full Documentation: View Web README →
The CHSwap Web App offers a clean and responsive interface for interacting with the deployed smart contract.
It’s powered by:
- ⚡ Vite + React + TypeScript
- 🪙 Celo + Wagmi + Viem
- 💅 TailwindCSS
- 🔌 Reown AppKit for wallet connection
cd Web
npm install
npm run devOpen your browser at
🔗 http://localhost:5173
| Layer | Stack | Description |
|---|---|---|
| Smart Contract | Solidity + Hardhat | Manages all swap logic and on-chain pricing |
| Frontend | React + Vite + Wagmi | Provides a user-friendly interface for token swaps |
| Blockchain | Celo | Handles all transactions and token balances |
| Wallet | Reown AppKit | Connects wallet and processes swap transactions |
| Category | Tools |
|---|---|
| Blockchain | Celo |
| Smart Contracts | Solidity + OpenZeppelin |
| Framework | Hardhat |
| Frontend | React + Vite |
| Styling | TailwindCSS |
| Wallet Integration | Reown AppKit |
| Environment | dotenv |
This project is licensed under the Apache License.
Built with ❤️ by Critterholes
Smart Contract Docs •
Frontend Docs