-1

I'm working on a project using hyperledger fabric 2.0. I have two chaincodes named deed.js and bor.js. Both the deed.js and bor.js are installed on the same channel. I have taken some input in deed.js chaincode which is to be passed as input to bor.js chaincode. How to do that?Please explain in detail about the method as I'm newbie to hyperledger fabric.

Thanks.

1 Answers1

0

Yes, there is.

A chaincode can query another chaincode (or itself) without modifying the ledger only if they both are running in the same peer.

It can even invoke another chaincode (or itself) to modify the ledger only if they both are running on the same channel in the same peer.

https://hyperledger.github.io/fabric-chaincode-node/release-2.1/api/fabric-shim.ChaincodeStub.html#invokeChaincode__anchor

No time for more detail, whether you are a newbie or not

kekomal
  • 2,179
  • 11
  • 12
  • peer0.org1.example.com:7051 and peer0.org2.example.com:9051 are anchor peers in my network for org1 and ogr2. Both of my chaincodes deed.js and bor.js are installed on both the org peers. Is it possible to send data between chaincodes in this case? – Satish Chandra Medi May 05 '20 at 09:29
  • YES, of course it is. You can invoke an operation of the second chaincode from the first one. I'm supposing both peers have joined the channel. – kekomal May 05 '20 at 09:44
  • I have called chaincode bor witin chaincode deed like this invokeChaincode(bor, deed, channel) where deed parameter is the data I want to send from chaincode deed to chaincode bor. After calling invokeChaincode function from deed chaincode, how can I receive data on second chaincode ? – Satish Chandra Medi May 05 '20 at 10:04
  • As with any other chaincode operation: https://hyperledger.github.io/fabric-chaincode-node/release-2.1/api/fabric-shim.ChaincodeStub.html#getArgs__anchor – kekomal May 05 '20 at 10:19