andyle83 / marketplace

Not a simple marketplace in Celo blockchain network
https://marketplace-andyle83.vercel.app/
3 stars 1 forks source link
blockchain celo dapp marketplace web3

Celo 101 - Marketplace

1. Introduce

This project implements a simple marketplace to manage / selling product. It's based on great course of Celo in the Dacade. It helps us to understand about Solidity, Celo blockchain, and how to make a fullstack application base on them.

The feature includes:

On-going implementation (by order)

Demo website: https://marketplace-andyle83.vercel.app/

2. Technology Stack

Blockchain

Backend [TBD]

Frontend

There are two variants of implementation:

3. Showcase

Marketplace

Home Page

Home Page

Wallet Connect

Add New Product

Purchase Product

Add New Product

Create Product

Create New Product

Purchase History

Create New Product

4. Testing

Running Unit Testing Smart Contract

npm run test
npx hardhat node
npx hardhat test
npx hardhat test --network alfajores

Running manual test (using Laika)

npx hardhat run scripts/sample-script.js --network alfajores

Output

No need to generate any newer typings.
Marketplace deployed to: 0xB67880E89e79aA1529532677Cc07e2ab007e6443
npx hardhat laika-sync --contract Marketplace --address 0xB67880E89e79aA1529532677Cc07e2ab007e6443

Laika Initialize

Laika New Product

Laika Get Number

5. TODO

vercel
vercel --prod

6. Useful commands

Celo-cli

celocli account:new
celocli config:get
celocli config:set --node=https://alfajores-forno.celo-testnet.org
celocli account:balance 0xbDEA9f367e9a92b41e91525AEC13d3aDFb027a68

Hardhat

npx hardhat console
npx hardhat accounts
npx hardhat clean
npx hardhat compile
npx hardhat node
npx hardhat test
npx hardhat test --network alfajores
npx hardhat run scripts/sample-script.js --network alfajores

Laika (similar as Postman)

npx hardhat laika-sync --contract Marketplace --address 0x052F92eF1B97c0dD68B7150a8BBeBf962dD8a4e7

7. Issues

  1. Not able to run in localhost. Solution

    • Start the hardhat node as in-memory local blockchain
    • Update hardhat configure with right address (localhost) and port
  2. Trying to insert concurrent (multi products) at the same time in Testnet, and get an issue

    Error: replacement fee too low [ See: https://links.ethers.org/v5-errors-REPLACEMENT_UNDERPRICED 
  3. Trying to make unit test for buyProduct but transaction was reverted with error:

    ProviderError: VM Exception while processing transaction: revert
    • Running hardhat in-memory blockchain npx hardhat node
    • Running unit test in hardhat node npx hardhat test --network localhost
    • Checking output in hardhat console log
eth_chainId
eth_getTransactionByHash
eth_chainId
eth_getTransactionReceipt
eth_chainId
eth_estimateGas
  Contract call:       Marketplace#buyProduct
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x0165878a594ca255338adfa4d48449f69242eb8f
  Value:               0 ETH

  Error: Transaction reverted: function call to a non-contract account
      at Marketplace.buyProduct (contracts/Marketplace.sol:88)
      at async EthModule._estimateGasAction (/Users/Anh.Le/Workspace/GitHub/celo-101/contract/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:425:7)
      at async HardhatNetworkProvider._sendWithLogging (/Users/Anh.Le/Workspace/GitHub/celo-101/contract/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:139:22)
      at async HardhatNetworkProvider.request (/Users/Anh.Le/Workspace/GitHub/celo-101/contract/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:116:18)
      at async JsonRpcHandler._handleRequest (/Users/Anh.Le/Workspace/GitHub/celo-101/contract/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:188:20)
      at async JsonRpcHandler._handleSingleRequest (/Users/Anh.Le/Workspace/GitHub/celo-101/contract/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:167:17)
      at async Server.JsonRpcHandler.handleHttp (/Users/Anh.Le/Workspace/GitHub/celo-101/contract/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:52:21)

Reference