input field:
Dissecting the 68 Bytes
The Ethereum ABI packs everything into 32-byte words preceded by a 4-byte function selector:Check your understanding: Why does transfer(address,uint256) have NO spaces or parameter names?
Check your understanding: Why does transfer(address,uint256) have NO spaces or parameter names?
The ABI specification hashes the canonical signature — function name + parenthesized, comma-separated canonical types (
uint256, never uint; no spaces, no parameter names). transfer(address to, uint256 amount) hashes to the wrong 4 bytes and your transaction will hit the fallback or revert.What Happens When a Type Has Variable Length?
Fixed types (address, uint256, bool, bytes32) sit inline in the head. Dynamic types (string, bytes, T[]) cannot fit in 32 bytes, so the head stores a byte offset pointer into the tail:
Notice the padding asymmetry that trips people up in hand-rolled decoders:
- Numbers & addresses are left-padded with zeros (
0000...abcd). bytes&stringare right-padded with zeros (68656c6c6f0000...).
Step-by-Step: Encode, Decode, and Parse Logs
1
Verify the selector and encode static calldata
2
Decode raw calldata without knowing which function was called
When indexing transactions, you have the contract ABI and raw
input bytes. abi.decodeData matches the 4-byte selector automatically:3
Encode and inspect dynamic head/tail parameters
Use
Abi.encodeParameters and Abi.decodeParameters directly when working with raw ABI parameter tuples (constructors, abi.encode, multicall payloads):4
Decode an ERC-20 Transfer event log
Events split fields across two places:
indexedparameters go intotopics[1..3](withtopics[0]=Keccak256("Transfer(address,address,uint256)")).- Non-indexed parameters are ABI-encoded into
data.
What You Built
- Decoded a 68-byte ERC-20 transfer manually by splitting selector + 32-byte words.
- Visualized how ABI head offsets point into dynamic tail slots.
- Encoded/decoded function calldata, standalone parameter tuples, and indexed
Transferevent logs usingAbi.

