In this track: ABI encoding foundations
advanced · 4 MIN READ

ABI encoding versus packed encoding

Compact concatenation has different boundaries and ambiguity properties.

LET’S PICTURE IT

Removing separators from a form saves space while making some field boundaries impossible to recover.

SEE IT FOR YOURSELF
Build a transfer call from typed fieldsStep 1 / 4
Build a transfer call from typed fieldstransfer(address,uint256)Recipient: 0x0000…0001Raw amount: 100Diagram labels abbreviate addresses; the lab shows full bytes4-byte selectora9059cbbEach box is one byte; this prefix is not a 32-byte wordWord 0 · recipient address12 zero bytes20 address bytes000…0001Left padding preserves the lower-order address valueSelector4 bytesa9059cbbAddress32 bytesword 0Amount32 bytesword 1 → 0x644 + 32 + 32 = 68 bytesThe integer does not contain token decimals or market price

The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.

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

Standard encoding uses full rules

Ordinary ABI encoding has typed words, offsets and lengths. The added structure lets a decoder with the schema locate dynamic components.

Packed encoding is a separate mode

For supported types, packed encoding can concatenate more compact representations. A uint16 pair such as 0x1234 and 0x5678 can occupy four bytes together rather than two full words.

Dynamic boundaries can collide

Packed strings ab and c produce the same concatenated bytes as a and bc. Hashing those identical bytes does not recover the missing boundary distinction.

Match the verifier’s exact construction

A signing or proof protocol must define types, framing and domain separation. Do not interchange encode and encodePacked merely because both produce hex data.

Follow the bytes

Packed uint16 pair: 0x12345678

Packed UTF-8 strings:
("ab", "c") → 0x616263
("a", "bc") → 0x616263

Same concatenated bytes; different intended fields.

This is an encoding ambiguity rather than a cryptographic hash failure.

TURN UNDERSTANDING INTO PRACTICEOpen the Keccak-256 →
QUICK CHECK · NO PRESSURE

Can packed ("ab","c") and ("a","bc") yield identical concatenated bytes?

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.