Dynamic arrays begin their tail with an element count.
LET’S PICTURE IT
A list first announces how many numbered entries the reader should expect.
SEE IT FOR YOURSELF
Follow a dynamic string from head to tailStep 1 / 4
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.
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.At argument byte 32, the string tail begins with length five. This counts the UTF-8 payload bytes and excludes all padding.At argument byte 64, read 68 65 6c 6c 6f for hello. Twenty-seven following zero bytes fill the final content word.The encoding uses ninety-six argument bytes: one offset word, one length word and one padded content word. A normal function call adds a four-byte selector before these bytes.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Keep the top-level pointer
A uint256[] argument is dynamic. Its head word points to its array encoding, even though each individual integer element has a static encoding.
Write the number of elements
For values 7 and 9, the array length word contains two. This is an element count, not the number of bytes used by the elements.
Place static elements directly
The two integer words follow the length in order. There is no per-element offset because uint256 values are static and each occupies one full word.
Check total encoded length
One outer offset word, one array length word and two element words make 128 bytes. A fixed uint256[2] type would use a different layout without the dynamic length prefix.
Trace a local example
types: uint256[]
values: [["7","9"]]
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
0x0000000000000000000000000000000000000000000000000000000000000009
Words: outer offset 32, count 2, value 7, value 9.