🔥 Live Demo 🔥
A decentralized exchange allow trading with BEP20 tokens using orderbook. The quote currency is BUSD. There are 2 trading options : limited order and market order. Users can create buy/sell limit/market orders. They can deposit/ withdraw tokens between their Metamask wallets and their Orderx.Exchange account.
- Orderx Exchange Contract: 0xFb2659C50778Ce810124B2b322dED92a7233C3eC
- BUSD Mock Token: 0xe97b2d94F82Eca0dE1c9D552aD4ABC1C8C3dD4ec
- WBNB Mock Token: 0x4F0c19f92eCEFcECC231F12818FE8D5f14608f5A
- CAKE Mock Token: 0xfBaAC96Fa9cf01bc5f851E978605827Ec4f357A0
- DOT Mock Token: 0xcDd3D1Df4c16c3d8eDbC930F08A0Ed8Ca689B375
User wallet (default to be Metamask) Frontend (Web app) Smart contract (Blockchain)
A frontend which is the Web app is connected to both user wallet and the smart contract. User uses the web app to interact with the Orderx smart contract. When sending any transaction, user wallet will prompt the user for confirmation.
Mock 4 BEP20 tokens (BUSD, WBNB, CAKE, DOT) for this project instead of interact with live tokens
Preset trade data and order data when deploy the contract in "2_deploy_contracts.js"
- Truffle v5.1.7 (core: 5.1.7)
- Solidity v0.6.3 (solc-js)
- Node v10.17.0
- Web3.js v1.2.1
- npm 6.11.3
- Ganache CLI v6.7.0 (ganache-core: 2.8.0)
- MetaMask V7.7.3
- Openzeppelin
-
Install Truffle:
npm install -g truffle
-
Install ganache-cli:
npm install -g ganache-cli
-
Install MetaMask in your browser (https://metamask.io/)
-
Install Openzepplin testing package*
npm install @openzeppelin/text-helpers
Launching local blockchain with Ganache
First launch the local testing blockchain with 10 default testing accounts which contains ETH. Open up a new seperate terminal, and run the following command:
>truffle develop
New blockchain listens on 127.0.0.1:9545 by default Copy the MNEMONIC seed to Metamask and connect Metamask as "LocalHost 9545" on the port listed above.
In order to keep development environment running, do not close this terminal
Clone the project
Open up another new terminal, make sure the ganache-cli terminal is running at the same time.
-
git clone
-
Move to the directory
npm install
-
Compile the contracts
truffle compile
-
Migrate to ganache-cli
truffle migrate --reset
-
Run tests. (All tests should pass)
truffle test
-
Run Dapp, move to frontend folder
cd frontend
-
Install the dependencies
yarn install
-
Run the App
yarn start
-
Or follow these Instructions
- http://localhost:3000/
- This Dapp requires to interact with MetaMask. When the dapp loaded, MetaMask pop-up will appear if installed properly, requesting your approveal to allow DEX Dapp connect to MetaMask wallet. Please choose Connect.