[英]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.