0 votes
1 view
in Blockchain by (11.8k points)

I am trying to write an application with hyper-ledger and I was looking for a way to communicate with chain-code from another chain-code. Is that possible in hyper-ledger?

I know its possible in etherum to communicate with other smart contracts but is the same possible in hyperledger. I could not find any related links related to same. Any suggestions on how to approach this will be really helpful.

1 Answer

0 votes
by (27.7k points)

Chaincode could interact with other chaincode by means of leveraging existing API of ChaincodeStubInterface, e.g.:

  •  InvokeChaincode locally calls the specified chaincode `Invoke` using the
  •  same transaction context; that is, chaincode calling chaincode doesn't
  •  create a new transaction message.
  •  If the called chaincode is on the same channel, it simply adds the called
  •  chaincode read set and write set to the calling transaction.
  • If the called chaincode is on a different channel,
  •  only the Response is returned to the calling chaincode; any PutState calls
  • from the called chaincode will not have any effect on the ledger; that is,
  •  the called chaincode on a different channel will not have its read set
  •  and write set applied to the transaction. Only the calling chaincode's
  •  read set and write set will be applied to the transaction. Effectively
  •  the called chaincode on a different channel is a `Query`, which does not
  •  participate in state validation checks in subsequent commit phase.
  •  If `channel` is empty, the caller's channel is assumed.
  • InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...