I am using IBM bluemix blockchain service to tryout some smart contract logic for my asset sharing demo.
Is there anyway to query the asset modified history in hyperledger fabric network.
I have checked with documentations for both fabric 0.6 and 1.0 versions, but I can find only the stub.pushState(key,value_json) and stub.getState(key) to interact width the ledger.
But using stub.getState(key), I can fetch only the latest entry of the key, but how can I fetch and display the series of changes/modification written for the same key.
I have iterated through the block using {peeraddress}/Block/getBlock/{Block}
, but I am getting the encrypted transaction payloads only since its security is on. I am not getting the idea to display the history of asset modifications for the same key.
Please suggest me the correct way to do this.
Thanks in advance
You can use
GetHistoryForKey()
API as following:Here is the link to the interface with API description:
In case you'd like to inspect history of changes not in context of chaincode you can use QSCC (Query System Chaincode), which provide following capabilities:
IF you need. Java SDk and go chaincode combination. Here is the example
and you go chancode implemetation is as follows
}
There you go. Have fun.
From the Fabric FAQ, A. The chaincode API GetHistoryForKey() will return history of values for a key.