The payload is right-padded while its length remains exact.
LET’S PICTURE IT
A partly filled shipping tray has empty spaces after its contents, but the item count stays unchanged.
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.
Distinguish bytes from bytes3
Dynamic bytes and fixed bytes3 can hold the same three content bytes but have different ABI layouts. Dynamic bytes needs a tuple offset and a length prefix.
Preserve payload order
For 0x123456, the payload starts with 12 34 56. Standard dynamic-byte encoding places zeros after the payload to reach the next word boundary.
Round content size upward
Three content bytes require twenty-nine padding bytes. Thirty-two content bytes require no extra content padding word; thirty-three require sixty-four padded content bytes.
Read using the declared length
The decoder uses the length to separate original data from padding. A zero byte inside the declared payload remains data and must not be trimmed merely because it is zero.
Trace a local example
types: bytes
values: ["0x123400"]
no function selector prefix
word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000020
word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000003
word 2 · argument offset 64 bytes
0x1234000000000000000000000000000000000000000000000000000000000000
Three payload bytes include a real final 00, followed by padding.