0

I write a simple contract to test the event like the following code:

pragma solidity ^0.6.12;

contract EventTest {
    address public router;
    event RouterUpdated(address indexed newAddress);
    
    function setRouter(address newAddress) public {
        router = newAddress;
        emit RouterUpdated(newAddress);
    }
}

Why the transaction event function name does not appear? Check result

1 Answers1

0

It's stored on the blockchain in the form of keccak256 hash of the event signature.

keccak256("RouterUpdated(address)") == 0x7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc80

It's not translated to the original RouterUpdated simply because Etherscan doesn't translate it to the human-readable form.

Since hash is a one-way function, this translation is usually done using a dictionary, where the key is the hash and the value is the input.

They translate function signatures to function names in some parts of their UI, but for some reason they chose not to translate the event signatures to event names.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • is there a way to register my event signature? or a list of events that can i use? – Mahmoud Khalid Jun 14 '21 at 17:49
  • There's no whitelist of allowed events, so you can define any event you like. But some standards (e.g. [ERC-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md) for regular tokens, or [ERC-721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md) for NFTs) define a list of events that you need to implement to follow the standard... Also the signature is generated automatically from the event definition. See [this answer](https://stackoverflow.com/a/66950423/1693192) for more info. It's about function signatures but the way to calculate the hash is the same. – Petr Hejda Jun 14 '21 at 19:35
  • i got it, Thanks a lot – Mahmoud Khalid Jun 14 '21 at 19:58