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!

greendino
  • 416
  • 3
  • 17
Young_Torso
  • 141
  • 1
  • 10

2 Answers2

3

There are two official SDKs you can try out.

  1. Fabric Java SDK
  2. Node JS SDK
Ajaya Mandal
  • 537
  • 4
  • 10
  • 1
    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. Thanks – Young_Torso Feb 15 '19 at 17:42
  • 2
    Did you have a watch on this? https://github.com/hyperledger/fabric-samples/tree/release-1.4/balance-transfer/app – Ajaya Mandal Feb 18 '19 at 06:23
  • @Ajaya Mandal, These SDKs are for Java, are there SDK for C++ and compatible with hyperledger besu? – Nayana Feb 21 '22 at 07:29
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++.

Aditya Arora
  • 303
  • 2
  • 12