This is a decentralized marketplace built for EVM compatible blockchains, it enables sellers and buyers from all around the world to buy and sell their products in secure and trustless manner, and even thought products are listed in $ (to avoid the volatility of the crypto market) all the payment are done using cryptocurrencies (ETH, MATIC,...) and all the purchase steps are controled by the MarketPlace smart contract logic.
Table of Contents
Please install or have installed the following:
- nodejs and npm
- python
- MetaMask Chrome extension installed in your browser
- Installing Request: Request is a node module that enhances the development, testing, and deployment of smart contracts, particularly for those who prefer to use JavaScript for writing their scripts. It complements Truffle by providing a streamlined experience for managing your smart contract workflows.
Here is a simple way to globally install request.
npm i -g request
- Clone the repo:
git clone https://gitlab.com/plusblue/dapp-marketplace.git
cd dapp-marketplace
Decentralized marketplaces are one of the best use cases of blockchains technologies. They allow people to interact and transact on a global, permission-less, and self-executing platform. Houses, hot sauce, and t-shirts can all be bought and sold without needing to trust a middleman and with smaller fees.
The application allow any user to add a product by providing the product name, description, price in $ and image.
The platform ensures a good interaction between the seller and the buyer by deviding the purchase process (product state) into 4 steps:
- In Sale: The first step when a seller list it's product on the market
- Pending: When a product is bought the amount paid is locked in the smart contract and buyer waits for seller to sent the product
- Sent: The seller sends the product and waits for the buyer confirmation
- Sold: The buyer confirms the recieval and the funds are transfered to the seller
All this steps can be performed on the product page:
Seller point of view:
Buyer point of view:
The user can find the list of products he is selling and that he is buying on the My product page:
The app is based on a single global contract called MarketPlace, it contains the following functions :
- Admin functions: Allow admin to change the fee charged for selling a product
- Seller functions: Allow a seller to add it's product, change it's price and sent it to the buyer
- Buyers functions: Allow buyer to purchase and confirm the recieval of any product
- Chainlink Price Feed: the contract uses the price feed provided by chainlink oracle for converting the products prices from $ to ETH
The user interface of this application is build using React JS, it can be started by running:
npm start
It uses the following libraries:
- Ethers.js: used as interface between the UI and the deployed smart contract
- Web3modal: for conecting to Metamask
- ipfs-http-client: for connecting and uploading files to IPFS
- @reduxjs/toolkit & redux-persist: for managing the app states (account, balance, blockchain)
- Material UI: used for react components and styles
The files are structured as follows:
- pages: Contains all the app views (MarketPage, ProductPage,...)
- Components: Contains all the app component(main, navbar, Account,...)
- features: contains the redux toolkit reducer and actions
- artifacts: contains all the smart contract data and addresses transfered earlier
- NetworksMap: a json file for some known blockchains names & chain id
Distributed under the MIT License. See LICENSE
for more information.
If you have any questions or suggestions, please feel free to contact us at cowchain610@gmail.com.