Search code examples
ethereumsolidityetherbinance-smart-chain

Transaction event function name does not appear


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


Solution

  • 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.