Re: Fabric-sdk-jAVA #fabric-sdk-java


Mark Lewis
 

The ContractEvent (fabric-gateway-java) and ChaincodeEvent (Fabric Gateway client API) that get delivered to you by contract/chaincode event listening both have getPayload() methods. Similar to the values returned by transaction invocation, these are binary (byte[]) payloads containing whatever data your smart contract put there. If it's string data you might want to turn it back into a string to view it. If it's JSON data, you might want to use a JSON parser.

If you really want to, you can extract the chaincode events from block events yourself. I would suggest looking at the fabric-gateway-java source to see how this is done:

https://github.com/hyperledger/fabric-gateway-java/blob/9389ffb2b5ff2f6fb4387687479ff332697ad1ff/src/main/java/org/hyperledger/fabric/gateway/impl/event/Listeners.java#L31-L49

The chaincode event listening provided by the Fabric Gateway client API actually uses a new service to directly retrieve only the chaincode events from the peer, precisely to avoid the overhead of retrieving the large amount of additional data contained in the block event, and the work of parsing that extremely complex data structure to extract the chaincode event at the client end.

Join fabric@lists.hyperledger.org to automatically receive all group messages.