In this track: Dynamic ABI and nested layouts
Build a dynamic encoding trace
Annotate byte positions before trying to memorize a long hex string.
A map becomes readable when each turn has an origin, distance and destination.
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.
Write the declaration and values
Use setMessage(string) with hello as a small reproducible request. Keep the declaration, canonical signature, typed argument and selector visible alongside the encoded output.
Divide framing and arguments
The first four bytes select the function. Label argument byte zero immediately afterward. The first argument word contains offset 32, so the string tail begins at calldata byte 36.
Annotate the tail
At that destination, the length word is five. The content begins at calldata byte 68 and contains hello followed by twenty-seven padding bytes.
Verify by changing one thing
Replace hello with an empty string or a thirty-three-byte ASCII string. Predict which lengths and total sizes change, then compare the locally generated bytes with your prediction.
Trace a local example
types: string
values: ["hello"]
no function selector prefix
word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000020
word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000005
word 2 · argument offset 64 bytes
0x68656c6c6f000000000000000000000000000000000000000000000000000000Parameter encoding shown here excludes the selector; add four to convert its positions to calldata positions.
Complete function input
function setMessage(string message)
arguments: ["hello"]
selector: 0x368b8772
arguments begin at calldata byte 4
word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000020
word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000005
word 2 · argument offset 64 bytes
0x68656c6c6f000000000000000000000000000000000000000000000000000000Here the selector is shown separately from the argument words.
Where does hello content begin in this function call?
Four selector bytes plus one offset word plus one length word equals 68.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.