javahyperledger-fabrichyperledger-fabric-sdk-java

How to insert the data into hyper-ledger fabric fabric network (block-chain) through REST APIs


I am planning to implement a block-chain based application for storing the electricity consumption records to a hyperledger fabric network. Is there any way to insert the data through REST APIs?


Solution

  • First of all you need to write the smart-contract (as per your use-case) and deploy that to the hyper-ledger fabric network. Then, you can create another application where you expose the REST endpoints. Maybe a Springboot application you can create with REST endpoints which can take the data requests and call the Smart-Contract's methods for creating the records.

    There is a Node.js/Express REST sample for the basic asset transfer chaincode in fabric-samples. When writing similar REST applications make sure you do not create new connections for every transaction, and think about how to handle errors and retries.