Skip to content

Amazon like e-commerce Dapp with open sales, customized stores, auctions system and product reviews built on the EVM blockchains

License

Notifications You must be signed in to change notification settings

kaymen99/web3-Ecommerce-dapp

Repository files navigation

Decentralized Marketplace Dapp V2

Dark

This is my second implementation of a decentralized E-commerce marketplace built on top of EVM-compatible Blockchains such as Ethereum and Polygon. The previous dapp only allowed users to buy and sell single items without quantity. However, this new version is much more advanced and includes a wide range of features. Users can now create their own stores with customized branding and sell products with limited or unlimited quantities. Additionally, buyers have the ability to review the products they purchase. I have also introduced an Auction market, inspired by popular NFT marketplaces like OpenSea, however my implementation is more generalized and accepts a variety of products. It's important to note that all payments within the marketplace remain with cryptocurrency tokens.

Dark

Built With

Table of Contents
  1. Getting Started
  2. How it Works
  3. How to Use
  4. Contact
  5. License

Getting Started

Prerequisites

Please install or have installed the following:

Installation

  1. Installing Brownie: Brownie is a python framework for smart contracts development,testing and deployments. It's quit like HardHat but it uses python for writing test and deployements scripts instead of javascript. Here is a simple way to install brownie.

     pip install --user pipx
     pipx ensurepath
     # restart your terminal
     pipx install eth-brownie
    

    Or if you can't get pipx to work, via pip (it's recommended to use pipx)

    pip install eth-brownie
    

    Install ganache-cli:

     npm install -g ganache-cli
  2. Clone the repo:

    git clone https://github.com/kaymen99/MarketPlace-Dapp-V2.git
    cd MarketPlace-Dapp-V2
  3. Install Ganache: Ganache is a local blockchain that run on your machine, it's used during development stages because it allows quick smart contract testing and avoids all real Testnets problems. You can install ganache from this link : https://trufflesuite.com/ganache/

    Next, you need to setup the ganache network with brownie :

    brownie networks add Ethereum ganache-local host=http://127.0.0.1:7545 chainid=5777
  4. Set your environment variables To be able to deploy to real testnets you need to add your PRIVATE_KEY (You can find your PRIVATE_KEY from your ethereum wallet like metamask) and the infura project Id (just create an infura account it's free) to the .env file:

    PRIVATE_KEY=<PRIVATE_KEY>
    WEB3_INFURA_PROJECT_ID=<< YOUR INFURA PROJECT ID >>
    

    You can choose to use ethereum testnets like rinkeby, Kovan or any other evm compatible testnet. You'll also need some eth in the testnet. You can get it into your wallet by using a public faucet.

  5. As infura recently removed its free IPFS gateway i used web3.storage api for storing data into IPFS, this api is as simple as infura it requires the creation of a free account and a new api token which you can do here, when you finish add your api token into the src/utils/ipfsStorage.js file:

     const web3storage_key = "YOUR-WEB3.STORAGE-API-TOKEN";

(back to top)

How it Works

Main Market

This is the core of the old version marketplace V1 and it's made for single items purchase , User can add a product by providing the product name, description, price in $ and image.

Capture d’écran 2022-03-03 à 22 36 53

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 Store

The dapp enables sellers to create their own order based stores, They can add limited and unlimited quantity products.

Store Page:


Seller Dashboard:

Each seller willing to create a new store must provide a name and the store logo:

Dark

On the product page you can find all details regarding the product(seller, quantity, price,...) and the reviews posted by previous buyers, When an order is created it goes through 3 main states:

  • PENDING: just created and waiting for seller acceptance
  • SENT: product sent and waiting for buyer recieval confirmation
  • COMPLETED: The order is complete so seller recieve payment and buyer can leave a review

store-product-page

Auction Market

User can start an auction for any type of products by providing name, description, starting price, auction duration (in hours), item image. Bidders can offer an initial bid and outbid if necessary without having to withdraw their fund on each bid, the highest bidder will be determined after the end of the auction clock

(back to top)

How to Use

Scripts

In the MarketPlace-Dapp-V2 folder you'll find a directory scripts, it contain all the python code for deploying your contracts and also some useful functions

The reset.py file is used to remove all previous contracts deployments from build directory:

brownie run scripts/reset.py

The deploy.py file allow the deployment to the testnet/local-network:

brownie run scripts/deploy.py --network=ganache-local

The update_front_end.py is used to transfer all the smart contracts data (abi,...) and addresses to the front end in the artifacts directory:

brownie run scripts/update_front_end.py

After running this 3 cammands, the MarketPlace contract is now deployed and is integrated with the front end

(back to top)

Testing

In the MarketPlace-Dapp-V2 folder you'll find a directory tests, it contain all the python code used for testing the smart contract functionalities

You can run all the tests by :

brownie test

Or you can test each function individualy:

brownie test -k <function name>

(back to top)

Front-end

The user interface of this application is build using React JS, it can be started by running:

cd front-end
yarn
yarn 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

(back to top)

Contact

If you have any question or problem running this project just contact me: aymenMir1001@gmail.com

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

About

Amazon like e-commerce Dapp with open sales, customized stores, auctions system and product reviews built on the EVM blockchains

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published