A single dynamic argument still has an offset word.
LET’S PICTURE IT
Even a document with one attachment keeps an index entry that points to the attachment.
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.
Start with the input tuple
A standalone string parameter encoding is an argument tuple containing one dynamic member. Its first word is the offset 32, not the string length.
Write the byte length
At byte 32, write the number of UTF-8 payload bytes. For hello that number is five. The length excludes its own word and any trailing padding.
Write and pad the content
The bytes 68 65 6c 6c 6f represent hello. Add twenty-seven zero bytes after that payload to finish a thirty-two-byte content block.
Check the total size
This example has three words: offset, length and padded content. That is ninety-six bytes before any function selector is added. Empty content is a separate case.
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
0x68656c6c6f000000000000000000000000000000000000000000000000000000
Three words: 32, 5, then the padded UTF-8 payload.