Using HyperLedger Fabric with C++ Application
Asked Answered
Z

2

6

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!

Zalea answered 14/2, 2019 at 18:56 Comment(3)
For the people who down voted this question. Why? can you explain it to the OP so everyone can learn.Matrass
@AquaticallyChallengedFish thanks, thats exactly what I was thinkingZalea
@Zalea Did you find a way to interact with smart contract from your c++ based dapp?Hungary
S
3

There are two official SDKs you can try out.

  1. Fabric Java SDK
  2. Node JS SDK
Sporogenesis answered 15/2, 2019 at 7:36 Comment(3)
I am aware of these but as I mentioned all of the examples seem to rely on manually entering the cli container and invoking the chaincode manually. I am struggling find any explanation or examples of how this is done in an automated manner. ThanksZalea
Did you have a watch on this? github.com/hyperledger/fabric-samples/tree/release-1.4/…Sporogenesis
@Ajaya Mandal, These SDKs are for Java, are there SDK for C++ and compatible with hyperledger besu?Hungary
I
2

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++.

Inoculation answered 22/2, 2020 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.