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:
- See products hosted on the Celo Blockchain
- Purchase products with cUSD and pay the owner
- Add your own products to the dApp
- Record purchase history
On-going implementation (by order)
- Pagination
- Searching
- Only verified merchant can add product
- Merchant can check income / revenue in total or by product
- Voting or commenting in purchased product (only customer who purchase can vote)
- Category (labeling product type)
- Tracking order
Demo website: https://marketplace-andyle83.vercel.app/
Blockchain
- Written in Solidity for Celo blockchain network
- Deploying in Celo testnet: https://alfajores-blockscout.celo-testnet.org/
- Deploy address:
0x052F92eF1B97c0dD68B7150a8BBeBf962dD8a4e7(can be changed) - Development framework: HardHat & Laika
Backend [TBD]
- Using ORM (i.e, Prisma) and Postgres database to store off-chain data / fall-over solution
- Heroku to host Postgres
Frontend
There are two variants of implementation:
-
Node.js application (
appfolder)- Webpack as module bundler
- Celo ContractKit
- Using jQuery to update UI component with simple even handler function
- Bootstrap UI framework
-
Next.js framework (
react-appfolder)- Using
use-contractkitlibrary - Apollo Client for GraphQL queries
- Bootstrap UI framework
- Using
Marketplace
- Desktop
- Mobile
Wallet Connect
Purchase Product
Create Product
Purchase History
Running Unit Testing Smart Contract
- Local network - Testing using hardhat gauche package:
npm run test- Local network - Testing using hardhat node:
npx hardhat node
npx hardhat test- Testing network:
npx hardhat test --network alfajoresRunning manual test (using Laika)
- Deploy in testnet:
npx hardhat run scripts/sample-script.js --network alfajoresOutput
No need to generate any newer typings.
Marketplace deployed to: 0xB67880E89e79aA1529532677Cc07e2ab007e6443- Sync:
npx hardhat laika-sync --contract Marketplace --address 0xB67880E89e79aA1529532677Cc07e2ab007e6443- CI/CD (Applying
Vercel)- Integration Testing: [TBD]
- CI/CD Pipeline
vercel
vercel --prod- New features
- Voting / Comment from customer
- Sorting / Pagination / Category
- Searching
- Multi-items checkout
- Buying history
- Recommendation (or any Personalization)
- Backend
- Using database to improve performance / or store "big" data like images
- Extra customer profile (email, phone). It helps customer engagement / personalization
- Administration features
- Not everyone can add new product / category (admin, group of admin)
- Selling reporting etc..
Celo-cli
- New account
celocli account:new- Check configure
celocli config:get- Set configure (for network)
celocli config:set --node=https://alfajores-forno.celo-testnet.org- Get balance (sample address)
celocli account:balance 0xbDEA9f367e9a92b41e91525AEC13d3aDFb027a68Hardhat
- Console (for configuration)
npx hardhat console- Accounts
npx hardhat accounts- Clean up
npx hardhat clean- Compile
npx hardhat compile- In-memory network
npx hardhat node- Testing
npx hardhat test
npx hardhat test --network alfajores- Deploy
npx hardhat run scripts/sample-script.js --network alfajoresLaika (similar as Postman)
- Syn command
npx hardhat laika-sync --contract Marketplace --address 0x052F92eF1B97c0dD68B7150a8BBeBf962dD8a4e7- 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
- 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
- Trying to make unit test for
buyProductbut 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