This repository contains the source code for an ERC-20 token and a decentralized exchange (DEX) implemented in Solidity, along with a JavaScript front-end application for visualizing the contract and providing a user interface.
- ERC-20 Token: The project includes an implementation of an ERC-20 token contract, which adheres to the standard interface for fungible tokens on the Ethereum blockchain. Users can transfer and manage balances of this token.
- Decentralized Exchange: The DEX contract allows users to exchange the ERC-20 token with Ether (ETH) and vice versa. The exchange functionality is decentralized, meaning it operates directly on the blockchain without relying on centralized intermediaries.
- Fee Structure: The exchange charges a small fee for each transaction, providing a cost-efficient alternative to regular centralized exchanges. Users can save on fees while securely exchanging tokens and ETH.
- Liquidity Provision: Users have the option to provide liquidity to the DEX by depositing both the ERC-20 token and ETH into the liquidity pool. In return, they receive a share of the transaction fees generated by the exchange. This incentivizes liquidity providers and enables them to earn profits.
contracts/intercases
: Contains the Solidity smart contract files.token.sol
: Implements the ERC-20 token functionality.exchange.sol
: Implements the DEX functionality, including token and ETH exchange, fee calculation, and liquidity provision.web_app/
: Includes the JavaScript front-end application for interacting with the smart contracts and visualizing the DEX contract.
- Node.js / NPM
To run and test the project locally, follow these steps:
- Clone the repository:
git clone https://github.com/Mykhailo-Sichkaruk/DEX
- Chamge directory
cd DEX
- Run
npx hardhat node
to create a local node. If the node starts successfully, you should see the following message in your terminal: "Started HTTP and WebSocket JSON-RPC server at https://localhost:8545." - Run in new terminal
npx hardhat run --network localhost scripts/deploy_token.js
to compile and deploy your token contract. Upon success, you should see the message: "Finished writing token contract address: ...". - Run
npx hardhat run --network localhost scripts/deploy_exchange.js
to deploy the exchange contract. Upon success, you should see the message: "Finished writing exchange contract address: ...". - Open
webapp/index.html
in you favorite browser.l free to modify and distribute the code according to the terms of the license.