This project is a decentralized application (dApp) that implements a token exchange. It allows users to trade different ERC20 tokens in a peer-to-peer manner. The application consists of a smart contract layer and a client-side user interface.
The typical workflow for a user is as follows:
- Connect Wallet: The user connects their Ethereum wallet to the application.
- Deposit Tokens: The user deposits the tokens they want to trade into the exchange's smart contract.
- Create Order: The user creates a new order, specifying the token and amount they want to get and the token and amount they want to give.
- Fill Order: Another user can see the open orders and choose to fill one.
- Withdraw Tokens: The user can withdraw their tokens from the exchange at any time.
The smart contract layer is the backbone of the application. It consists of two main contracts:
Exchange.sol: This contract handles the core logic of the exchange. It manages user balances, orders, and fees.Token.sol: This is an ERC20 token contract with a faucet feature that allows users to get free tokens for testing purposes.
The smart contracts are developed using Solidity and are deployed on the Hardhat and/or Foundry local networks, as well as the Ethereum Sepolia testnet.
Stack: Solidity, Hardhat / Foundry, OpenZeppelin.
The client component is a React-based UI that allows users to interact with the smart contracts in a seamless and intuitive way.
Stack: React, Redux Toolkit, ethers.js, Tailwind CSS, shadcn/ui.
- Node.js: >=22.0.0
-
Clone the repository:
git clone https://github.com/edyionescu/dex-token-exchange.git
-
Install the dependencies for the client:
cd client npm install -
Install the dependencies for the smart contracts:
cd ../contracts npm install
-
Start the local blockchain:
cd contracts npm run node # Hardhat node (default) npm run node-foundry # Optional
-
Deploy the smart contracts:
cd contracts npm run deploy # Hardhat deployment npm run deploy-foundry # Optional
-
Seed the exchange with initial liquidity:
cd contracts npm run seed # Hardhat seeding npm run seed-foundry # Optional
-
Start the client:
cd ../client npm run dev -
Visit the application at
http://localhost:5173/.


