Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HyperLedger Fabric with C++ Application

So I am considering HyperLedger Fabric to use with an application I have written in C++. From my understanding, the interactions i.e. posting retrieving data is all done in chaincode, in all of the examples I have seen this is invoked by using the CLI interface docker container.

I simply want to be able to store data produced by my application on a blockchain.

My question is how do I invoke the chaincode externally, surely this is something that is able to be done. I saw that there was a REST SDK but this is no longer supported so I don't want to go near it, to be honest. What other options are available??

Thanks!

like image 315
Young_Torso Avatar asked Feb 14 '19 18:02

Young_Torso


People also ask

Which language is best for Hyperledger Fabric?

To start as a developer, you need to know that the easiest way to code in chaincode and develop smart contracts for Hyperledger Fabric is to use the JavaScript programming language (though you can also use Java, Python or Go).

What can you do with Hyperledger Fabric?

Hyperledger Fabric networks can improve supply chain processes by increasing transparency and traceability of transactions within the network. On a Fabric network, companies with access to the ledger can view the same immutable data, which enforces accountability and reduces the risk for counterfeiting.

Does Hyperledger Fabric support smart contracts?

In the spirit of expanding choices, Hyperledger Fabric now supports Ethereum Virtual Machine (EVM) bytecode smart contracts. Contracts can now be written in languages such as Solidity or Vyper.


2 Answers

There are two official SDKs you can try out.

  1. Fabric Java SDK
  2. Node JS SDK
like image 149
Ajaya Mandal Avatar answered Oct 20 '22 21:10

Ajaya Mandal


As correctly mentioned by @Ajaya Mandal, you can use SDKs to automate the invoking process. For example, you can start the node app as written in app.js of balance transfer example and you can hit the API like it is shown in ./testAPI.sh file. echo "POST invoke chaincode on peers of Org1 and Org2" echo VALUES=$(curl -s -X POST \ http://localhost:4000/channels/mychannel/chaincodes/mycc \ -H "authorization: Bearer $ORG1_TOKEN" \ -H "content-type: application/json" \ -d "{ \"peers\": [\"peer0.org1.example.com\",\"peer0.org2.example.com\"], \"fcn\":\"move\", \"args\":[\"a\",\"b\",\"10\"] }")

Here you can add your arguments and pass it as you wish. You can use this thread to see how you can pass an HTTP request from C++.

like image 37
Aditya Arora Avatar answered Oct 20 '22 21:10

Aditya Arora