This project contains two parts: a Smart Contract backend using Hardhat and a React Web App frontend using Vite.
The smart contracts are located in the contracts folder. They contain a custom ERC20 Token implementation and a simple Automated Market Maker (AMM) Swap logic allowing swapping Token A for Token B.
- Navigate to the
contractsdirectory. - Create a
.envfile based on.env.example:cp .env.example .env
- Add your
PRIVATE_KEY(must be from a wallet like MetaMask that has Sepolia test Ethereum) andSEPOLIA_RPC_URL(can get free from Alchemy or Infura). - Run the deploy script to Sepolia:
npx hardhat run scripts/deploy.js --network sepolia
(This will deploy your custom Tokens and AMM contract onto the Sepolia testnet and place the contract addresses in the frontend automatically.)
The web application is located in the frontend directory. It comes with an elegant, modern "Glassmorphism" UI incorporating a Swap interface and a Live Coin Tracker using the CoinGecko API.
- Navigate to the
frontenddirectory:cd frontend - Run
npm install - Run
npm run devand open your browser tohttp://localhost:5173/
We've set up everything for you to host it easily on GitHub!
- Make sure your local codebase is connected to a GitHub Repository.
- In the
frontendfolder'spackage.json, add your repository URL if not present. - Open a terminal in the
frontenddirectory and run:npm run build npx gh-pages -d dist
- It will push the
dist/branch togh-pagesbranch on your GitHub. Go to your Github Repo -> Settings -> Pages -> Select branchgh-pagesto complete hosting.