How can I listen for contract events without specifying exact contract address? #3635
-
Hi, for example when I would like to listen for all Transfer() events for ERC tokens, how can I listen for all of them instead of specifying exact addresses to listen? I know I can create Contract and listen .on() event, which proceed automatic parsing, etc. But is there any way, how to listen all data from created Contract object but without passing exact address? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Till now, this is my best approach:
So I created event monitoring via websocket provider, pass idEvent encoded via pre-created contract object and then I decode returned log again via contract interface. But I believe it would be much better to have this inside the Contract token. |
Beta Was this translation helpful? Give feedback.
-
That isn’t something built-in, but you can create a provider and an Interface instance, and inside the provider listener, parse the log: const iface = new Interface(abi);
provider.on(filter, (log) => {
const event = iface.parseLog(log);
// …
}); |
Beta Was this translation helpful? Give feedback.
That isn’t something built-in, but you can create a provider and an Interface instance, and inside the provider listener, parse the log: