TrustChain is a blockchain-based solution that aims to create consumer trust in products by tracking their raw materials throughout the supply chain. It allows consumers to verify the origin, authenticity, and journey of a product by leveraging blockchain technology.
TrustChain is a platform that enhances transparency and builds trust between consumers and manufacturers. By tracking the entire supply chain on Hyperledger Fabric Blockchain, TrustChain provides consumers with access to valuable information about the product's raw materials, sourcing, and production processes.
- Secure Account Creation: Each member of the supply chain, excluding consumers, can create a dedicated account with a private key(for blockchain transaction) and secret code(for user authentication) for data security.
- Token Creation: Only Farmers can create tokens for their raw materials, establishing a verifiable and unique identity for each item.
- Ownership Transfer: Raw material ownership can be securely transferred from farmers to wholesalers, ensuring a transparent and auditable supply chain.
- Product Manufacturing: Wholesalers can create new tokens based on existing ones, representing the products manufactured using the raw materials.
- Transfer to Retailer: Manufacturers can transfer the newly created product tokens to retailers, streamlining the distribution process.
- Consumer Purchase: Retailers sell products to consumers, and the corresponding token is locked to maintain the integrity of the product's metadata.
- Product Tracking: Consumers can track the entire supply chain journey of a product by using its unique token ID.
Verify that you have the following installed:
$ node -v
v16.20.0
$ npm -v
8.19.4
$ docker -v
Docker version 23.0.1, build a5ee5b1
$ docker-compose -v
Docker Compose version v2.15.1
$ git --version
git version 2.39.2
-
Clone the repository
$ git clone https://github.com/raj-71/supply-chain-fabric.git $ cd supply-chain-fabric
-
Start the hyperledger fabric network
$ ./fablo up fablo-config.json $ cd backend/config $ ./generate-ccp
-
Start the backend server
$ cd backend $ npm install $ node app.js
- Organizations
- Farmer
- Wholesaler
- Retailer
- 1 Peer per Organization
- 1 Orderer of channel
CouchDB
as Database
-
createToken
- to generate a token for a produce only by farmer -
transferFrom
- when someone sells a token to other user -
createTokenOverToken
- when someone create a product from raw material, new tokens are created over those tokens -
lockToken
- when retailer sells product to consumer, no new metadata can be added to that token -
readNFT
- read data of a token from the ledger only if the user owns it -
readAllNFT
- read all the tokens that the user owns -
getHistory
- get all the transactions related to that token
Incase if any of the commands fail due to configurations or the network was not brought down properly use the following commands to clear the corrupted docker images and fix the issue.
-
Stop the network
$ ./fablo down
-
Again Up the network
$ ./fablo up fablo-config.json
-
Stop the containers
$ docker stop $(docker ps -a -q)
-
Remove the containers
$ docker rm $(docker ps -a -q)
-
Remove all local volumns
$ docker volume prune
-
Remove all wallets
$ cd backend $ rm -rf /backend/*-wallet
-
Authorization error code 71 -> Regenerate all connection profies in backend
$ cd backend/config $ ./generate-ccp
-
Incase of affiliation error -> authorization error code 20
Copy paste these lines in all the fabric-ca-server-config.yaml (total 4 such files) files in the network. File locations:
/fablo-target/fablo-config/fabric-ca-server-config/*.supplychain.com/fabric-ca-server-config.yaml
affiliations: farmer: - department1 seller: - department1 consumer: - department1