In this track: Dynamic ABI and nested layouts
advanced · 5 MIN READ

Dynamic arrays of static tuples

The array is dynamic even when every tuple element has fixed width.

LET’S PICTURE IT

A variable-length list can contain records with exactly two fixed fields each.

SEE IT FOR YOURSELF
Follow a dynamic string from head to tailStep 1 / 4
Follow a dynamic string from head to tailArgument headbyte 0 · offset 32hex word ends in 20String tailstarts at byte 32length + contentPositions are measured from argument byte zero, excluding any selectorOffset destinationargument byte 32read a length wordLength = 5hello is five UTF-8 bytescontent starts at byte 64A length word and an offset word have different jobsContent word · argument byte 6468 65 6c 6c 6f5 payload bytes27 padding bytesBlocks are schematic; their drawn widths do not represent the exact byte ratioHeadoffset: 32argument byte 0Tail lengthlength: 5argument byte 32Tail contenthello + paddingargument byte 6432 + 32 + 32 = 96 bytesWith a four-byte selector, total calldata length is 100 bytes

This example encodes one string parameter with value hello. A dynamic argument uses an offset in its head, even when it is the only argument.

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

Classify both layers

A (uint256,bool) tuple is static and occupies sixty-four bytes. An array of those tuples with type (uint256,bool)[] is dynamic because the number of records can vary.

Write the array prefix

The top-level argument points to the array length. For two records, the length is two, followed by the encodings of both tuples in their declared order.

Flatten each static record

Record one contributes its integer then its boolean. Record two contributes the same fields. There are no per-record pointers because each tuple is static.

Compute width from the schema

Four record words plus one count and one top-level offset total six words, or 192 bytes. Do not assume one array element always equals one word.

Trace a local example

types: (uint256,bool)[]
values: [[["7",true],["9",false]]]
no function selector prefix

word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000020

word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000002

word 2 · argument offset 64 bytes
0x0000000000000000000000000000000000000000000000000000000000000007

word 3 · argument offset 96 bytes
0x0000000000000000000000000000000000000000000000000000000000000001

word 4 · argument offset 128 bytes
0x0000000000000000000000000000000000000000000000000000000000000009

word 5 · argument offset 160 bytes
0x0000000000000000000000000000000000000000000000000000000000000000

Two records expand into four words after the array count.

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

How many words does one (uint256,bool) record use?

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.