AleRapchan / hyperledger-supply-chain

Food supply chain is a Hyperledger blockchain based solution which solves the tracking and tracing of food products in the supply chain so that any product can be traced back to its roots.
MIT License
20 stars 16 forks source link

How to run this on my system. #12

Open prateek951 opened 2 years ago

prateek951 commented 2 years ago

Hi guys @AleRapchan @alexeipancratov Just wanted to know how can I run this project on my system especially Windows. I am using Windows Subsystem for Linux, Docker Desktop Application and Ubuntu command line on Windows. I also have virtualbox installed onto my system but could not make Hyperledger to work on virtualbox.

Could you share a detailed link using in which I can setup the entire project on my system ?

Thanks

pushkar803 commented 1 year ago

Step 1. Start Hyperledger network and deploy the chaincode

Switch to project folder

$ cd hyperledger-supply-chain

Switch to the network folder

cd network/fabric-network

Start network

./network.sh up createChannel -ca -s couchdb

Deploy the chaincode

./network.sh deployCC -ccn supplychain -ccp ../../chaincode -ccl typescript

On mac u can face error like 'Hyperledger Fabric Chaincode Installation Failed - no matching manifest for linux/arm64/v8' https://stackoverflow.com/questions/69699421/hyperledger-fabric-chaincode-installation-failed-no-matching-manifest-for-linu

docker pull --platform linux/x86_64 hyperledger/fabric-nodeenv:2.2

Step 2. Generate user certificates

Switch to the following folder:

cd hyperledger-supply-chain/web-app/server/fabric

Remove previously generated certificates

rm -R wallet/*

If u running first time then

npm i

Run the following commands in sequence to generate identity certificates for admin and manager/employee users.

node enrollAdmin.js

node registerUsers.js

Step 3. Run API

Switch to the web API folder

cd hyperledger-supply-chain/web-app/server

Start the server

node app

During POST api hit u can get error like network _test not found https://stackoverflow.com/questions/65932112/the-name-of-hyperledger-fabric-test-network-is-not-detected-by-an-application-gi

export COMPOSE_PROJECT_NAME=net

If u get error like failed constructing descriptor for chaincodes:<name:"basic" >

in network.js u have to change

const CONTRACT = 'supplychain';

To stop and clean

cd network/fabric-network   
./network.sh down

Postman collection

https://elements.getpostman.com/redirect?entityId=6299967-75d770be-1491-4eca-98b2-5ba1f5c8e7dc&entityType=collection