Is there any way to recognize if a log contains an anonymous topic? From what I can tell is that anonymous events are represented in a log without the signature on the first index. Giving the option to include 4 instead of 3 topics. That would be a way to recognize them, however what if an anonymous event generates a log with less than 4 topics?

I need to find a couple of logs with anonymous events so that I can study them.


1 Answer 1


In a non-anonymous event, topics[0] will be the signature of the event name. In an anonymous event, the signature of the event name is not a topic.

If you have access to the ABI or the source code of the contract, here is what you could do:

  1. Find the signature hash of the event name.
  2. Check if topics[0] is equal to this signature. If not, you have an anonymous event.

If you don't have access to the ABI or the source code, I don't think that it is possible because there is no way to know if topics[0] is the event name signature or a bytes32 indexed argument.

On a side-note, the JSON ABI would indicate if an event is anonymous (see the docs).

  • Ok so if I understand correctly. A log can therefore always have a max of 4 topics. When the event is anonymous it has a max of 4 topics. When the event isn't anonymous it has a signature on topic[0] and 3 topics. Only if I have the ABI, I can say for sure that the signature is on topic[0]. Dec 16, 2021 at 20:35
  • That's my understanding, yes. Unless someone can think of another way...
    – Undead8
    Dec 16, 2021 at 20:36

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.