Mal*_*J S 2 blockchain hyperledger hyperledger-fabric
我正在尝试使用超级账本编写一个应用程序,并且我正在寻找一种与另一个链码的链码进行通信的方法。这在超级账本中可能吗?
我知道在以太坊中可以与其他智能合约进行通信,但在超级账本中也是可以的。我找不到与此相关的任何相关链接。关于如何解决这个问题的任何建议都会非常有帮助。
我查看了编写您的第一个应用程序,但找不到合适的解释。
Chaincode 可以通过利用现有的 API 与其他 chaincode 进行交互,例如ChaincodeStubInterface:
// 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
Run Code Online (Sandbox Code Playgroud)
以下是如何使用它的示例:
response := stub.InvokeChaincode(chaincodeName, chainCodeArgs, channelName)
Run Code Online (Sandbox Code Playgroud)
当然,peer 应该有权限并安装链代码。
| 归档时间: |
|
| 查看次数: |
1044 次 |
| 最近记录: |