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

Fixed-size arrays in the ABI

A fixed count does not automatically make the entire value static.

LET’S PICTURE IT

A shelf with two spaces can still hold expandable bags rather than fixed-size boxes.

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.

Know element type and count

uint256[2] holds two unsigned integer elements. Standard ABI encoding places their full element encodings in order. This static array occupies sixty-four bytes.

Dynamic elements change classification

string[2] has a fixed element count but dynamic elements. Its ABI layout is dynamic and uses offsets for variable-size data under the tuple rules.

There is no dynamic length prefix for a static array itself

A fixed array’s count is part of the schema. Do not prepend a length word merely because you are encoding an array; distinguish it from a dynamic array.

Inspect the actual schema

A decoder needs both element type and count. The same bytes can fit other combinations of static fields, so raw length does not establish the intended array type.

Follow the bytes

types: uint256[2]
values: [["1","2"]]
no function selector prefix

word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000001

word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000002

There are two data words, not a length word followed by two more.

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

Does uint256[2] prepend its own dynamic-array length word?

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.