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

Encode a boolean word

The boolean schema uses canonical zero or one values.

LET’S PICTURE IT

A yes/no form uses two agreed numeric states rather than any arbitrary nonzero label.

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.

False and true have canonical forms

A standard ABI bool is encoded like a word containing zero for false or one for true. It still occupies thirty-two bytes in ordinary parameter encoding.

Do not import loose language truthiness

A JavaScript object or the text false is not automatically a typed boolean value. Parse input according to the tool’s schema rather than assuming every programming language treats the same input identically.

Decoding needs the intended type

A word containing one can also be read as an integer under another schema. The bytes do not independently announce that the author intended a boolean.

Keep packed layouts separate

A packed encoding can use fewer bytes for bool. That is a distinct representation with different concatenation and decoding properties, not a reason to shorten a standard ABI word.

Follow the bytes

types: bool,bool
values: [false,true]
no function selector prefix

word 0 · argument offset 0 bytes
0x0000000000000000000000000000000000000000000000000000000000000000

word 1 · argument offset 32 bytes
0x0000000000000000000000000000000000000000000000000000000000000001

The second word ends in 01, while the first is entirely zero.

TURN UNDERSTANDING INTO PRACTICEOpen the ABI encoder →
QUICK CHECK · NO PRESSURE

How many bytes does one bool occupy in standard ABI parameter encoding?

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.