In this track: ABI encoding foundations
advanced · 4 MIN READ

Calculate a function selector

Keep the first four bytes of the canonical signature’s Keccak-256 digest.

LET’S PICTURE IT

A short action label is derived from a longer fingerprint, not assigned by the user-interface button.

SEE IT FOR YOURSELF
Build a transfer call from typed fieldsStep 1 / 4
Build a transfer call from typed fieldstransfer(address,uint256)Recipient: 0x0000…0001Raw amount: 100Diagram labels abbreviate addresses; the lab shows full bytes4-byte selectora9059cbbEach box is one byte; this prefix is not a 32-byte wordWord 0 · recipient address12 zero bytes20 address bytes000…0001Left padding preserves the lower-order address valueSelector4 bytesa9059cbbAddress32 bytesword 0Amount32 bytesword 1 → 0x644 + 32 + 32 = 68 bytesThe integer does not contain token decimals or market price

The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Hash exact signature text

For transfer(address,uint256), encode the canonical signature as text and calculate Keccak-256. Ethereum’s Keccak-256 differs from finalized SHA3-256. The choice of algorithm matters.

Take four bytes

The selector is the first eight hexadecimal digits after 0x, representing four bytes. The full digest remains thirty-two bytes; shortening it creates the possibility of collisions.

Prefix a standard function request

The selector precedes encoded arguments in ordinary function calldata. Return data and standalone ABI parameter encoding do not use this prefix automatically.

Verify locally

Hash the signature text in the Keccak tool and compare its first-four-byte output with the encoder’s transfer result. No signature database or chain call is required.

Follow the bytes

function transfer(address to, uint256 amount)
arguments: ["0x0000000000000000000000000000000000000001","100"]

selector: 0xa9059cbb
arguments begin at calldata byte 4

word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000001

word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000064

The standard transfer selector is 0xa9059cbb.

TURN UNDERSTANDING INTO PRACTICEOpen the Keccak-256 →
QUICK CHECK · NO PRESSURE

How many hexadecimal digits represent the selector after 0x?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.