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

ABI: the contract’s interface

Turn a function name and typed arguments into bytes.

LET’S PICTURE IT

An ABI is the form both sides agree to use: this field is an address, this one is a number, and this action has a specific name.

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.

An interface, not the whole program

The Application Binary Interface describes functions, arguments, return values, events and errors. It lets a wallet or app construct calls and interpret results. It does not explain every permission or guarantee that the deployed code matches your expectations.

Pick a function with four bytes

For transfer(address,uint256), take Keccak-256 of that exact canonical signature, then keep its first four bytes: 0xa9059cbb. That selector starts the calldata. A selector is short, so collisions are possible; it is not a globally unique identity.

Encode the arguments

An address is left-padded to a 32-byte word. A uint256 also occupies a 32-byte word. Dynamic values such as strings use offsets and separate data sections. Decode using a known interface: arbitrary bytes do not tell you their intended types by themselves.

Try both directions

Use the ABI encoder for transfers, approvals, strings and custom function declarations. Then paste its result into the calldata decoder. The trace separates the selector, raw words and decoded arguments so you can connect the readable request with its binary representation.

TURN UNDERSTANDING INTO PRACTICEOpen the ABI encoder →
QUICK CHECK · NO PRESSURE

How long is a standard function selector?

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.