0

This might seem like a weird question . But i want to know if it is possible to access a GO language chaincode installed in the peers from Composer script file .

That is in script.js file of the BNA file is it possible to access the GO Lang chaincode installed in the peers from Hyperledger Fabric side .

I want to invoke a chaincode 'mycc' from the script.js file and try to call 'mycc' functions from Composer

Any suggestions? Also an example would be good . Thanks !

Skadoosh
  • 699
  • 2
  • 11
  • 27

1 Answers1

3

It is possible to invoke another chaincode from a Composer transaction script. You would need to use the getNativeAPI() function. It is introduced in the Composer documentation halfway down in this document where I think the example uses the native api to access the 'current' network (chaincode).

There is an additional example in this tutorial where the getNativeAPI().invokeChaincode method is used to connect to a different Business Network.

I have not seen other examples, but this should work for connecting to other chaincodes.

R Thatcher
  • 5,550
  • 1
  • 7
  • 15
  • So you are saying i can do something like getNativeAPI().invokeChaincode('mycc',channelID,) ? – Skadoosh Aug 24 '18 at 05:17
  • 1
    there is an example here of invokeChaincode (and observe the caveats pointed out there - it mentions 1.0 obviously you're using a later Fabric version) -> https://stackoverflow.com/questions/49360796/how-we-can-call-one-chaincode-from-another-chaincode-in-fabric-1-0-if-anyone The parameters for invokeChaincode are shown here : https://fabric-shim.github.io/ChaincodeStub.html#invokeChaincode – Paul O'Mahony Aug 24 '18 at 10:26
  • @PaulO'Mahony this link is useful .my question is will i able to do this from my javascript file in composer .go to go code is possible . javascript to go ? if so then great . – Skadoosh Aug 27 '18 at 08:04
  • yes, in your script .js file, you can call your go chaincode and should be able to pass arguments to select which specific chaincode function it wants to invoke. – Paul O'Mahony Aug 28 '18 at 09:11