Skip to main content
Scenario: A block explorer hands you this raw hex blob from a mainnet transaction’s input field:
To most developers, that looks like noise. In five minutes, you will read it at a glance — and encode/decode both static and dynamic ABI payloads with Voltaire.

Dissecting the 68 Bytes

The Ethereum ABI packs everything into 32-byte words preceded by a 4-byte function selector:
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 & string are 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:
  • indexed parameters go into topics[1..3] (with topics[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 Transfer event logs using Abi.
Next tutorial: Tutorial 3: Building a Gasless Permit Relayer