I'm trying to read an event only when it has a specific value, for that I declared my event like so:
event eventName(int indexed filterNumber, string messageTitle, string messageDef);
Call it like so from the solidity smart contract:
Message(filterNumber, messageTitle, messageDef);
The event works, but I want to read it only if the filterNumber is a specefic one, to acomplish this I do the following:
var events = communicationChannelInstance.allEvents({'filterNumber': 54},
function(error, log){
if (!error)
eventHandler(null, log);
});
(Example trying to read only the messages with a filterNumber 54)
But this system still reads all the events even wen they are sent with a different filternumber.
Am I doing the filter corectly? I tried to follow the documentation but this is as far as I got.
Best Answer
If you look at the documentation for
allEvents
here it makes clear that you options object is not valid.I would get all of the events, and loop through them. You can then check if the property equals 54 and act accordingly.