Method ID

What is a Method ID?

Ethereum relies on a unique identifier, known as a Method ID or a function selector, to differentiate between different functions or methods within a smart contract.

Method ID is the first 4 bytes of the Keccak-256 hash of the function signature that specifies which functions to be called. The function signature includes the function name and its parameters' types which are separated by a single comma, with no spaces in between.

Example of a Keccak-256 hashed function signature

The Method ID for the function signature is the first 4 bytes (or the first 8 digits) of the Keccak-256 hash.

For functions of contracts that have been verified on Etherscan, the function name will be displayed in the 'Method' column in Transactions page.

Retrieve the corresponding Method ID by going to:

Transaction details page > Input Data field

We automatically match functions for an unverified contract with known functions from verified contracts on Etherscan by comparing bytecode using a process called Similar Match.

As a result, the Method ID displayed for this function may not be 100% reliable.

The Method ID is derived from known functions of verified contracts on Etherscan

For unidentified functions, the Method ID is displayed instead:

💡
Learn how to easily filter for all transactions on Ethereum involving a specific Method ID.

Method ID Collision

Since only the first 4 bytes of a hashed function signature are used, Method ID collisions have a possibility to occur.

For example, the Method ID 0x00000000 may represent more than one function signature:

Source: www.4byte.directory

Trolls or malicious actors may use these collisions to fool you. Always be mindful of this when browsing Methods on Etherscan!

  • Teck Yuan Lee
Updated