首页 > 解决方案 > 从 Hyperledger Fabric Node SDK 中的函数 InvokeChaincode() 获取链码调用方 ID

问题描述

让我们假设以下网络架构:

A -> Chaincode1 -> fabcar

A是应用程序,Chaincode1是 Go 中的链码,fabcar是 Nodejs 中的链码。他们在同一个频道:“mychannel”。

何时APIstub.InvokeChaincodeChaincode1执行操作,例如,chaincode fabcar(被调用的chaincode)APIstub.InvokeChaincode("fabcar", chainCodeArgs, "mychannel")是否有可能获取调用者chaincode 的id

fabcar链码中的getCreator()方法只返回调用者组织;但所需的信息是链码 ID或仅连接到Chaincode1的一些信息。


更新

我尝试了超级账本官方文档中写的方法: httpsgetSignedProposal() ://fabric-shim.github.io/ChaincodeStub.html#getSignedProposal__anchor

getSignedProposal()方法返回类型为 的已签名交易提案的完全解码对象SignedProposal。该SignedProposal对象表示客户端应用程序向链码发送的请求对象。

执行以下代码:

const proposal = stub.getSignedProposal();
console.log("signed proposal: ", proposal);

结果如下:

signed proposal:  { signature: <Buffer 30 45 02 21 00 c3 a7 91 4c 74 f9 c2 97 04 fc 84 91 6a 71 2d 69 ad 0e a9 22 f2 ed 53 a3 66 97 56 17 d7 d7 3a e6 02 20 13 26 8a 4f f6 3d 86 4e f9 35 ae ... >,
  proposal:
   { header: { signature_header: [Object], channel_header: [Object] },
     payload: { input: [Object], TransientMap: [Object] } } }

似乎真的很难理解哪些是可以检索调用链代码 ID的信息。这是有关SignedProposal类型的文档的链接:https ://fabric-shim.github.io/global.html#SignedProposal

标签: node.jsgohyperledger-fabricblockchainhyperledger

解决方案


不,目前不可能这样做,因为链码本身没有身份。


推荐阅读