Video tutorial: Watch on YouTube
A simple Uniswap V2-style token swap interface built with HTML + JS + MetaMask + Ethers.js.
- Frontend:
public/index.html,public/swap.js - Example contracts:
contract/factory.sol,contract/router.sol(placeholders for your own UniswapV2-compatible contracts)
If you want your own Factory/Router. The repo includes placeholders in contract/ — you can replace them or point to your own.
-
Deploy contracts
- Deploy your Factory contract.
- Deploy your Router contract and link it to the Factory.
-
Prepare tokens
- Add liquidity or approve token spending for the Router.
-
Configure frontend
- Update
routerAddressinswap.js.
- Update
-
Run locally
cd public python3 -m http.server
Once deployed, update the frontend addresses:
- Open
public/swap.js - Set
routerAddressto your deployed router - Update
tokenAddressesto the ERC-20 tokens on your network