1

How come sometimes events show up on block explorers in hex and sometimes to you can see the actual string name of the event in the logs. I ask because my event watchers on my front end only pick up the events that render in plain english, and I'm not sure how to rationalize this

0

The blockchain only stores a hash of the event name and its parameter types. For example, if the event is defined as:

emit Transfer(address _from, address _to, uint256 _amount);

The blockchain stores the keccak256 hash of "Transfer(address,address,uint256)". The name Transfer is not stored at all.

Block explorers maintain a large list of many common event names, parameters and their associated hashes. That's why they can often work backwards and figure out the name and parameter types from the hash. But if the name is not in their table, they can't figure it out, and the best they can do is display the raw hex.

  • good explanation, but how can i watch for a Transfer event using ether for example. on my own contracts, i can write contr.on("EventName", () => {}). But I seem to have a hard time catching events on erc20s – Michael C Dec 12 '19 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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