Skip to content

critterholes/Swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🦄 CHSwap — Celo Token Swap Ecosystem

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.


📂 Project Structure

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.


⚙️ Part 1 — Smart Contract

🗁 Location: /Contract
📄 Full Documentation: View Contract README →

🔧 Overview

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

🛠 Setup & Deployment

1. Clone the repository

git clone https://github.com/critterholes/Swap.git
cd Swap/Contract

2. Install dependencies

npm install

3. 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 celo

5. Verify Contract (optional)

npx hardhat verify --network celo <contract-address> "<chp-address>" "<usdc-address>"

💻 Part 2 — Web Frontend

🗁 Location: /Web
📄 Full Documentation: View Web README →

🧠 Overview

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

🧭 Quick Start

cd Web
npm install
npm run dev

Open your browser at
🔗 http://localhost:5173


🌐 Architecture Summary

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

🧹 Tech Stack

Category Tools
Blockchain Celo
Smart Contracts Solidity + OpenZeppelin
Framework Hardhat
Frontend React + Vite
Styling TailwindCSS
Wallet Integration Reown AppKit
Environment dotenv

📜 License

This project is licensed under the Apache License.


Built with ❤️ by Critterholes
Smart Contract DocsFrontend Docs

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •