1

I'm trying to recreate the ABI of an event function (that I don't have the ABI for). I have looked at event ABIs in other contracts of the same project and they all look like this:

{"anonymous":False,"inputs":[{"indexed":True,"internalType":"address","name":"_minter","type":"address"}],"name":"MinterAdded","type":"event"}

I have copied this format and changed the function name and inputs. Filtering logs for this event with web3py works just fine, but calling eventname().processLog() to decode the data of such a log raises LogTopicError: Expected 5 log topics. Got 0.

Indeed the event function has 5 inputs whose values are all provided in the data field of the log dictionary. And besides the default topic there are no additional topics.

So web3py expects those inputs to be reflected in the topics and not the data. How do I denote those inputs as data so that web3py reads and decodes the corresponding values in the data field?

I know I can easily decode it myself, but I want to use web3py's API where possible, it's much cleaner.

1 Answer 1

1

As it turned out, setting indexed to True means that the parameter is logged and can be filtered for. If indexed is set to False they are provided as data.

Changing indexed from True to False for all inputs fixed the error and made eventname().processLog() work as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.