![](/img/trans.png)
[英]how to display current hash,previous hash using node js on view pages for hyperledger fabric
[英]Hyperledger Fabric Version 2: How to query Block Header such as data hash, previous hash by using Fabric Node SDK 2.2
我正在尝试构建一个去中心化的应用程序,它能够在用户提交新交易时显示块 header 之类的数据 hash,之前的 hash 块。 但是,新版本的Fabric Node SDK 2.2似乎删除了 function 查询块。
I refer on the documentation at https://hyperledger.github.io/fabric-sdk-node/release-2.2/module-fabric-network.html and currently still looking for some workaround to show the block info of the user's transaction.
我希望实现的理想 output 与 Hyperledger Explorer 提供的几乎相似。参考可以在以下位置查看:
其中显示了有关 hash 的块数、数据 Hash、以前的 Hash 和其他块信息等信息。
在blockData
接口中有一些信息,例如 BlockEvent,其名称为BlockEvent
。 但是,当npm install i fabric-network
时,我似乎找不到它。
由于用户可以通过账本查询查看自己的hash,因此需要在交易成功后将key或者hash返回给用户。 有没有 API function 呢? 到目前为止,我发现 class Transaction
中有getTransactionId()
。 但这是我需要使用的吗?
所有参考自处理旧版本节点 SDK 即版本 1.4。
您可以通过调用qscc
合约的 function GetBlockByNumber
来查询区块号。 例子:
const contract = network.getContract('qscc');
const resultByte = await contract.evaluateTransaction(
'GetBlockByNumber',
channelName,
String(blockNum)
);
const resultJson = BlockDecoder.decode(resultByte);
logger.debug('queryBlock', resultJson);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.