0

I have assets whose state get updated and I want get history of that asset with previous_hash and current Block_hash. I am using CouchDB as State DB of Hyperledger Fabric.

I tried fabcar example function 'getHistoryForAsset' but it can give me only TxID but I need Block hash with this.

Can anybody help me how can we do it.

Thanks

Abhirock
  • 425
  • 6
  • 17

1 Answers1

0

Using the transaction ID you can call (evaluate) the GetBlockByTxID transaction function on the system qscc chaincode to get the block that contained that transaction. It expects a transaction ID as an argument and returns a common.Block protobuf response payload.

https://github.com/hyperledger/fabric-protos/blob/f44816d6f621f1f7615cb4fc65643791eb6d8ce6/common/common.proto#L142

Note that a block only contains the hash of the previous block, not the hash of itself.

bestbeforetoday
  • 1,302
  • 1
  • 8
  • 12