I'm using fabric version 1.4. I have deploy my contract fabcar on first network. I have do some modification in that existing contract like add SetEvent("initLedger",[]byte{"test"}). And what I want is to listen these events using my below code but not able to fetch events. Here is my code:-
CODE
//connect to Fabric Network, but starting a new gateway
const gateway = new Gateway();
//use our config file, our peerIdentity, and our discovery options to connect to Fabric network.
await gateway.connect(ccpPath, { wallet, identity: peerIdentity, discovery: { enabled: true, asLocalhost: true } });
console.log('gateway connect');
//connect to our channel that has been created on IBM Blockchain Platform
const network = await gateway.getNetwork('mychannel');
//connect to our insurance contract that has been installed / instantiated on IBM Blockchain Platform
const contract = await network.getContract('fabcar');
await contract.addContractListener('my-contract-listener', 'InitLedger', (err, event, blockNumber, transactionId, status) => {
if (err) {
console.error(err);
return;
}
//convert event to something we can parse
event = event.payload.toString();
event = JSON.parse(event)
//where we output the TradeEvent
console.log('************************ Start Trade Event *******************************************************');
console.log(`make: ${event.type}`);
console.log(`model: ${event.ownerId}`);
console.log(`colour: ${event.id}`);
console.log(`owner: ${event.description}`);
console.log(`Block Number: ${blockNumber} Transaction ID: ${transactionId} Status: ${status}`);
console.log('************************ End Trade Event ************************************');
});
While I'm running this code in console it will print nothing. If I'm missing something or any suggestions please welcome or suggest me.