MiniSwap is a decentralized exchange (DEX) built on the Ethereum blockchain, specifically designed for the Sepolia test network. It allows users to swap between two custom ERC20 tokens and provide liquidity to the exchange.
- Wallet Integration: Connect your MetaMask wallet to interact with the DEX
- Token Swapping: Swap between two custom ERC20 tokens (TT1 and TT2)
- Liquidity Provision: Add liquidity to the exchange to earn trading fees
- User-Friendly Interface: Clean and intuitive UI for all DEX operations
- Real-time Updates: Automatic updates for wallet connection and transaction status
- Node.js (v16 or later)
- MetaMask browser extension
- Sepolia Test Network configured in MetaMask
- Test ETH on Sepolia network (can be obtained from Sepolia Faucet)
miniswap/
├── contracts/ # Smart contracts
│ ├── DEX.sol # Main DEX contract
│ ├── Token1.sol # First ERC20 token
│ └── Token2.sol # Second ERC20 token
├── frontend/ # Next.js frontend application
│ ├── src/
│ │ ├── app/ # Next.js app router
│ │ ├── components/ # React components
│ │ ├── context/ # React context providers
│ │ └── contracts/ # Contract ABIs and addresses
│ └── public/ # Static assets
└── README.md # Project documentation
The project includes three main smart contracts:
-
DEX.sol: The main decentralized exchange contract that handles:
- Token swaps
- Liquidity provision
- Price calculations
- Fee management
-
Token1.sol & Token2.sol: Custom ERC20 tokens used for trading on the DEX
The frontend is built with:
- Next.js 15
- React 19
- TypeScript
- Tailwind CSS
- Ethers.js
- Web3Context: Manages wallet connection and blockchain interaction
- DEXInterface: Main interface for token swapping and liquidity provision
- WalletButton: Persistent wallet connection button
git clone https://github.com/yourusername/miniswap.git
cd miniswap
# Install frontend dependencies
cd frontend
npm install
Create a .env.local
file in the frontend directory with the following variables:
NEXT_PUBLIC_DEX_ADDRESS=your_dex_contract_address
NEXT_PUBLIC_TOKEN1_ADDRESS=your_token1_contract_address
NEXT_PUBLIC_TOKEN2_ADDRESS=your_token2_contract_address
cd frontend
npm run dev
The application will be available at http://localhost:3000
- Click the "Connect Wallet" button in the top right corner
- Approve the connection request in MetaMask
- Ensure you're connected to the Sepolia test network
- Enter the amount of TT1 and TT2 tokens you want to provide
- Click "Add Liquidity"
- Approve the token transfers in MetaMask
- Confirm the liquidity addition transaction
- Select the swap direction (TT1 → TT2 or TT2 → TT1)
- Enter the amount you want to swap
- Click "Swap Tokens"
- Approve the token transfer in MetaMask
- Confirm the swap transaction
- Always verify you're on the Sepolia test network
- Never share your private keys or seed phrases
- Double-check transaction details before confirming
- Use test tokens only for development purposes
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.