The following are the instructions to run the backend of the carpoolingDApp. There are two processes to it which are
- Starting the Hyperledger network
- Starting the server
Prerequisites:
For Hyperledger Fabric —> Docs link
For this project -->
- MySQL
- IPFS (Interplanetary File Storage)
Process 1:
- Start the Hyperledger network, create a channel and deploy the chain code with the following steps:
- Clone the fabric-samples repository from hyperledger here.
- Up and create a channel on the test-network from fabric-samples with instructions from here. Follow this up until you have created a channel, and deploy the chaincode-javascript dir as chaincode to the channel using the steps given.
- Clone this repository to your local system and deploy the folder chaincode-javascript as the network’s channel’s chaincode.
Process 2:
1. Start the server: Navigate to this repository and run the following commands to start the simple express server.
npm installnpm run dev
Working of the App:
Three parts to the app:
- Hyperledger Network with the chaincode (chaincode-javascript) deployed to the channel
- Hyperledger Fabric API Gateway (application-javascript)
- Express.js Server (server.js)
Workflow:
When the server receives a request,
- It calls the imported methods from the gateway to complete the transactions
- The gateway in turn calls the methods in the chaincode which performs IPFS actions, adds the transaction to a local SQL database and completes the transaction in the blockchain as well.
The recorded transaction can be viewed in the blockchain with the peer chaincode queries as given here.
Resources to understand further:
Official Hyperledger Fabric Docs: https://hyperledger-fabric.readthedocs.io/en/release-2.5/
A Quick Theoritical Overview: https://kctheservant.medium.com/a-quick-overview-of-hyperledger-fabric-348e8c4da451