Skip to content

TeckYuanLee/CarbonReviews

Repository files navigation

CarbonReviews

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.

CarbonReviewsPoster

How it's made

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

Demo Video

Watch our demo video here

Link references

To run program

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

To use

Please watch our demo video here

Program functionalities

Smart Contract (YourContract.sol)

  1. Provision of review tokens via giveToken(address _userAdd, uint _productId)

    • if new user address (_userAdd) or product (productId) is passed into function, users and products will be updated with new product.
    • 1 review token will be credited to users-tokens' mapping
  2. Display number of review tokens for each user via displayTokens(address _userAdd, uint _productId) return function

  3. Token is used via writeReview(uint _productId, string memory _reviewHash) in conjunction with verification of tokens with hasToken(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
  4. 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)

Store and retrieve data to/from IPFS/web3storage

  1. Storing data - storeJson(json_obj, filename)
    • returns IPFS/web3storage CID
  2. Retrieving data - getJson(hashKey)
    • return stored json.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published