{"id":22938926,"url":"https://github.com/hardworking-toptal-dev/dex-solidity","last_synced_at":"2025-04-01T19:45:03.162Z","repository":{"id":235643289,"uuid":"791053554","full_name":"hardworking-toptal-dev/dex-solidity","owner":"hardworking-toptal-dev","description":"dex-solidity","archived":false,"fork":false,"pushed_at":"2024-04-24T02:27:16.000Z","size":938,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T15:50:02.297Z","etag":null,"topics":["dex","solidity"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardworking-toptal-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-24T02:26:46.000Z","updated_at":"2024-09-10T13:26:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"35464583-10af-4482-ba1e-70ad139f91ca","html_url":"https://github.com/hardworking-toptal-dev/dex-solidity","commit_stats":null,"previous_names":["eric-potter/dex-solidity","hardworking-toptal-dev/dex-solidity"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardworking-toptal-dev%2Fdex-solidity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardworking-toptal-dev%2Fdex-solidity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardworking-toptal-dev%2Fdex-solidity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardworking-toptal-dev%2Fdex-solidity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardworking-toptal-dev","download_url":"https://codeload.github.com/hardworking-toptal-dev/dex-solidity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246704797,"owners_count":20820616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dex","solidity"],"created_at":"2024-12-14T12:28:58.182Z","updated_at":"2025-04-01T19:45:03.144Z","avatar_url":"https://github.com/hardworking-toptal-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"`#Ethereum`\r\n\r\n# mTC DExchange\r\n\r\nThis is a Decentralized Exchange built with smart contracts powered by Ethereum. It basically consists in a platform where the user can exchange an ERC-20 token called mTC Token by Ether in a secure and descentralized manner.\r\n\r\n## Table of Contents\r\n\r\n- [Getting Started](#getting-started)\r\n- [The Project](#the-project)\r\n- [Resources](#resources)\r\n\r\n## Getting Started\r\n\r\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes.\r\n\r\n### The repository\r\n\r\nFirst, you will need to `clone` or `fork` the repository into your Github account:\r\n\r\n\u003cimg src=\"https://docs.github.com/assets/images/help/repository/fork_button.jpg\" alt=\"Fork on GitHub\" width='450'\u003e\r\n\r\n```\r\n$ git clone https://github.com/miquelTC/decentralized-exchange.git\r\n```\r\n\r\n### Installing\r\n\r\nFirst, you will need to install the dependencies with: `npm install`.\r\n\r\nRun the following command in your terminal after cloning the main repo:\r\n\r\n```\r\n$ npm install\r\n```\r\n\r\nThen, you will need to install Truffle globally by running the following command int your terminal:\r\n\r\n```\r\n$ npm install -g truffle\r\n```\r\n\r\n### Running the Tests\r\n\r\nFirst, you will have to compile the smart contracts by running the following command in your terminal:\r\n\r\n```\r\n$ truffle compile\r\n```\r\n\r\nThen you will have to install and run Ganache to run your blockchain locally:\r\n\r\nhttps://www.trufflesuite.com/ganache\r\n\r\nThen, the tests that validate your solution can be executed by runing the following\r\ncommand:\r\n\r\n```\r\n$ truffle test\r\n```\r\n\r\n### Deployment on Local Blockchain\r\n\r\nDeploy the contracts on your Ganache local blockchain by running the following command:\r\n\r\n```\r\n$ truffle migrate\r\n```\r\n\r\n### Seed your Local Blockchain\r\n\r\nRun the following script create some transactions on your smart contracts (orders, trades...):\r\n\r\n```\r\n$ truffle exec scripts/seed-exchange.js\r\n```\r\n\r\n### Opening the User Interface\r\n\r\nFirst of all, it is required to install Metamask wallet as a browser extension: https://metamask.io/\r\n\r\nThen you should configure Metamask to connect to your local blockchain run by Ganache. This requires the following:\r\n- Open Metamask\r\n- Open the Network Configuration panel\r\n- Open Custom RPC\r\n- Configure your private network by adding `http://localhost:7545` on the URL and `1337` as a chain ID.\r\n- Import the first Ganache Account to Metamask by copying the Account Private Key from Ganache and pasting it on Metamask\r\n\r\nFinally you just need to run the following command in your terminal to open the User Interface:\r\n\r\n```\r\n$ npm start\r\n```\r\n\r\n### Deployment on Public Network\r\n\r\nIn order to deploy your smart contract, you must create your .env file and specify:\r\n\r\n- `PRIVATE_KEYS` --\u003e Private Key of the account you are using to deploy (typically the first one in the list of Ganache)\r\n- `INFURA_API_KEY` --\u003e API key provided by Infura: https://infura.io\r\n\r\nThen, you will need to run the following command (let's use the testnet Ropsten in this example, remember to request some Ether for your account using a faucet):\r\n\r\n```\r\n$ truffle migrate --network ropsten\r\n```\r\n\r\nAnd also seed your exchange by running this command:\r\n\r\n```\r\n$ truffle exec scripts/seed-exchange.js --network ropsten\r\n```\r\n\r\nFinally you can run the following command to generate the build artifacts of your User Interface and then deploy to your favourite host:\r\n\r\n```\r\nnpm run build\r\n```\r\n\r\n\r\n### Technology stack\r\n\r\n- `Solidity`\r\n- `React`\r\n- `Truffle`\r\n- `Web3.js`\r\n- `Ganache`\r\n- `Node.js`\r\n- `Metamask`\r\n\r\n## The Project\r\n\r\nThis project consists in a decentralized exchange to allow users making p2p trades between Ether and a ERC-20 token called mTC Token. It includes:\r\n\r\n- A smart contract which contains an ERC-20 token called mTC Token\r\n- A smart contract which contains a decentralized exchange and all the logic to submit orders, execute trades...\r\n- Tests built with JavaScripts to ensure smart contracts are accomplishing the expected functionalities\r\n- A React.js front-end application as a user interface\r\n\r\n### Project architecture\r\n\r\n\u003cimg src=\"./img/architecture.PNG\" alt=\"architecture\"\u003e\r\n\r\nThe user can access the application via web-browser, and he must have the Metamask wallet installed. This interface, built with React.js, relies on the web3.js library to communicate with the smart contracts through Metamask. This means that the data reflected on the front-end application is fetched from the Ethereum blockchain. Each action performed by the user (put a a buy order, cancel order, execute a trade...) creates a transaction on Ethereum, which will require Metamask confirmation and pay an small fee, and this transaction will permanently modify the state of the Token and Exchange smart contracts.\r\n\r\n### Exchange features\r\n\r\n\u003cimg src=\"./img/layout.PNG\" alt=\"layout\"\u003e\r\n\r\nThere are several sections which have different functionalities for the end user:\r\n\r\n#### Balance\r\n\r\nHere is where the user can deposit / withdraw Ether or mTC Token in the Exchange. It also reflects the balances, not only exchange balances but also wallet ballances,\r\n\r\n#### New Order\r\n\r\nThe user can place either a buy order or a sell order at a chosen price. This order will be placed in the Order Book as soon as the transaction is completed.\r\n\r\n#### Order Book\r\n\r\nHere the user can see all the orders placed. Also, the user can execute the trade by only clicking in a particular order in this Order Book.\r\n\r\n#### Price Chart\r\n\r\nThe Price Chart reflects the price of the mTC Token via candlestick chart.\r\n\r\n#### My Transactions\r\n\r\nThis reflects the activity done by the user who connected the Metamask. It shows the trades executed by the user and also the placed orders.\r\n\r\n#### Trades\r\n\r\nThis section contains the full list of trades executed by any user in this decentralized exchange.\r\n\r\n## Resources\r\n\r\n- [ethereum.org](https://ethereum.org/)\r\n- [truffle suit](https://www.trufflesuite.com/)\r\n- [node.js](https://nodejs.org/)\r\n- [web3.js](https://web3js.readthedocs.io/)\r\n- [react.js](https://reactjs.org/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardworking-toptal-dev%2Fdex-solidity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardworking-toptal-dev%2Fdex-solidity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardworking-toptal-dev%2Fdex-solidity/lists"}