链代码可以与其他链代码交互吗?

Can a chaincode interact with other chaincode?

我正在尝试使用超级分类帐编写一个应用程序,并且我一直在寻找一种与来自另一个链代码的链代码进行通信的方法。这在超级账本中可能吗?

我知道在以太坊中可以与其他智能合约进行通信,但在超级账本中也是如此。我找不到任何相关链接。关于如何解决这个问题的任何建议都将非常有帮助。

我查看了 Writing Your First Application,但找不到合适的解释。

链码可以通过利用 ChaincodeStubInterface 的现有 API 与其他链码交互,例如:

// 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

以下是如何使用它的示例:

response := stub.InvokeChaincode(chaincodeName, chainCodeArgs, channelName)

当然 peer 应该有权限和安装链代码。