Re: smart contract A invoking function from smart contract B #fabric-chaincode


Mark Lewis
 

There is an invokeChaincode() function available on the chaincode stub that can be used to make chaincode-to-chaincode calls:

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

But your smart contracts are both within the same chaincode so you don't need to use that. Instead, you might want to define a function that implements the transaction behaviour you want to invoke from both smart contracts, and call that implementation function from both transaction functions. So you would have two separate transaction functions (on separate smart contracts) that share some or all of their implementation.

Join {fabric@lists.hyperledger.org to automatically receive all group messages.