首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >调用另一个链码的链码(超级分类账结构)

调用另一个链码的链码(超级分类账结构)
EN

Stack Overflow用户
提问于 2018-08-01 10:24:22
回答 3查看 676关注 0票数 0

我有一个由3个orgs和两个频道组成的网络。

channelone:org1,org2,chaincode- fabcar

信道两种:org1,org3,链码- fabphone

我想用法布卡查询链码--法布卡电话。

EN

回答 3

Stack Overflow用户

发布于 2019-10-15 15:12:46

您可以使用stub.InvokeChaincode方法从另一个链码中调用-

代码语言:javascript
运行
复制
response := stub.InvokeChaincode(chaincodeName, invokeArgs, channelName)
if response.Status != shim.OK {
  return nil
}

return response.Payload

有关详细信息,请参阅- https://sourcegraph.com/github.com/hyperledger/fabric/-/blob/core/chaincode/shim/interfaces.go#L62:3

票数 0
EN

Stack Overflow用户

发布于 2020-04-12 06:48:02

如果您用javascript或typescript编写链码,您可以使用以下代码:

代码语言:javascript
运行
复制
const args = [functionName, ...]
const result = await ctx.stub.invokeChaincode(chaincodeName, args, channelName)

return result.payload.toString('utf8')
票数 0
EN

Stack Overflow用户

发布于 2018-08-02 15:35:54

我认为这是不可能的。您只能在同一通道内调用链码函数。函数invokeChaincode使用与原始事务相同的事务上下文。查看一下https://github.com/hyperledger-archives/fabric/blob/master/core/chaincode/shim/chaincode.go

代码语言:javascript
运行
复制
// InvokeChaincode locally calls the specified chaincode `Invoke` using the
// same transaction context; that is, chaincode calling chaincode doesn't
// create a new transaction message.
func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, function string, 
args []string) ([]byte, error) {
return handler.handleInvokeChaincode(chaincodeName, function, args, stub.UUID)
}

// QueryChaincode locally calls the specified chaincode `Query` using the
// same transaction context; that is, chaincode calling chaincode doesn't
// create a new transaction message.
func (stub *ChaincodeStub) QueryChaincode(chaincodeName string, function string, args 
[]string) ([]byte, error) {
return handler.handleQueryChaincode(chaincodeName, function, args, stub.UUID)
}
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51630962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档