-
Hello :) How can I filter logs on a receipt based on the name of an event ? Should I use This is what I'm doing using web3:
Thank you :) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Up <3 |
Beta Was this translation helpful? Give feedback.
-
You can use the Contract API which understands how to build the ABI encoded structures you need. Then you can just use But if you just want to do things like this, the way Solidity emits an event is by using the hash of the normalized event name as the first topic. So, for example, if your method was |
Beta Was this translation helpful? Give feedback.
-
(moving this to discussions) |
Beta Was this translation helpful? Give feedback.
You can use the Contract API which understands how to build the ABI encoded structures you need. Then you can just use
contract.queryFilter("ContertUpgrade", fromBlock, toBlock)
to get a list of the events, which will also include all the values parsed and decoded for you.But if you just want to do things like this, the way Solidity emits an event is by using the hash of the normalized event name as the first topic. So, for example, if your method was
function foo(address bar)
you would use the hashethers.utils.id("foo(address)")
. You can look through here to learn more about how events are processed internally, but I highly recommend you just use the Contract API. :)