Dragon Swap is an implementation of an AMM (Automated Market Maker) contract in Solidity along with a front-end user interface that allows a user to connect and interact with the AMM contract.
To get started with this project, follow these steps:
- Clone this repository.
- Install dependencies with
npm install. - Run the local hardhat blockchain node with
npx hardhat node. - Run the react client server with
npm start. - Add the Hardhat network to a blockchain wallet such as MetaMask and connect to it.
- Import the first 5 Hardhat accounts (Account #0, Account #1, Account #2, Account #3, Account #4) onto MetaMask (https://support.metamask.io/managing-my-wallet/accounts-and-addresses/how-to-import-an-account/#importing-using-a-private-key).
- Deploy the contract to the local hardhat blockchain with
npx hardhat run scripts/deploy.js --network localhost. - Seed the AMM by running
npx hardhat run scripts/seed.js --network localhost. - Connect to the website with any of the imported Hardhat accounts and interact with the AMM by swapping tokens, depositing liquidty, withdrawing shares and charting the price of tokens. Enjoy!
To run the tests, use the following command: npx hardhat test
If the application does not work, you can try the following troubleshooting steps:
- Clear activity and nonce data: Select the Hardhat network and Hardhat account on MetaMask that you are using to interact with the AMM, click the 3 vertical dots on the top right of the MetaMask extension, click "Settings", click "Advanced", Click "Clear activity tab data" and then Click "Clear".
- Change the network from Hardhat to another network (like ETH Mainnet) and back to Hardhat on the MetaMask extension.
- Keep in mind that everytime the Hardhat node is restarted, you must run the deploy and seed scripts again and might have to repeat the above MetaMask specific steps for the application to perform appropriately.
