setEvent is not sending the contect

jay park

Hi Team,

I put event in chaincode but it seems the contents is not coming to the client, only event name is coming.
Could you please let me know how to receive the contents that I set in the chaincode?

I set event in chaincode and use 2.4.2.

In client, code is like below and use fabric network 2.2.15.

try {
      listener = async (error, event) => {
        this.logger.debug("registerEvent 2", transaction.getTransactionId());        const trevent = event.getBlockEvent().getTransactionEvents()
        console.log("getTransactionEvents : ",trevent);
        console.log("getContractEvents : ",trevent[0].getContractEvents()[0].payload );
        console.log("getContractEvents : ",trevent[0].getContractEvents()[0].getTransactionEvent());
      const mspId = network.getGateway().getIdentity().mspId;
      const peers = network.getChannel().getEndorsers(mspId);
    await network.addCommitListener(listener, peers, transaction.getTransactionId());


Mark Lewis

The commit listener is intended only to check for the commit status of submitted transactions at peers. For performance, it uses filtered blocks, which do not contain chaincode event payloads. If you want to see chaincode events then you should use a contract event listener, which will deliver you chaincode events and include the event payload. This also has the benefit of ensuring you get chaincode events delivered in order, exactly once. Using a (persistent) checkpointer alongside your contract event listener will allow you to resume listening at exactly where you left off, event following an application restart.