Welcome to CarbonReviews! This project is inspired by the decentralized nature of blockchain technology which enables reviews stored to be immutable and tamper-proof. When reviews are written to the blockchain, anyone can verify the reviews of a product and make better informed decision on their purchases.
As environmental concerns continues to grow, we believe it will be a good start to utilise an immutable and tamper-proof review system for consumers to rate the carbon footprint of products available in the market. When consumers compare the CarbonReviews of a product, they will get to choose products that are actually friendly for the environment. Companies can also compete to produce products that are more eco-friendly to have a better image to its consumers.
We used Scaffold-eth (https://github.com/austintgriffith/scaffold-eth) to build our smart contract and the front end UI. Reviews can only be posted by users with a review token supplied by the smart contract. We then used web3storage to store reviews written by users, and subsequently store the CID returned into our smart contract. Each review is mapped to the product and the reviewer address to ensure its authenticity.
Other references: a_blockchain_based_system_for_online_consumer_reviews.pdf / ethereum_mitigating_review_frauds.pdf
Prerequisites: Node plus Yarn and Git
clone/fork 🏗 scaffold-eth:
git clone
install and start your 👷 Hardhat chain:
yarn install
yarn chain
in a second terminal window, start your 📱 frontend:
yarn start
in a third terminal window, 🛰 deploy your contract:
yarn deploy
Please watch our demo video here
-
Provision of review tokens via
giveToken(address _userAdd, uint _productId)
- if new user address (
_userAdd
) or product (productId
) is passed into function,users
andproducts
will be updated with new product. - 1 review token will be credited to users-tokens' mapping
- if new user address (
-
Display number of review tokens for each user via
displayTokens(address _userAdd, uint _productId)
return function -
Token is used via
writeReview(uint _productId, string memory _reviewHash)
in conjunction with verification of tokens withhasToken(uint _productId)
.- if user has review token for specific product, total number of tokens will be deducted by 1 upon spending for review submission
- reviewHash in the form of IPFS CID will be stored in blockchain
-
Display/return review, functions available to:
- return single review -
displayReview(address _userAdd, uint _productId, uint reviewIndex)
- return all reviews for single product -
displayMultipleReviewsProduct(uint _productId)
- return all reviews for single user -
displayMultipleReviewsUser(address _userId)
- return single review -
- Storing data -
storeJson(json_obj, filename)
- returns IPFS/web3storage CID
- Retrieving data -
getJson(hashKey)
- return stored json.