A fixed-size byte value differs from a variable-length byte sequence.
LET’S PICTURE IT
A four-slot tray and an expandable bag hold data under different size rules.
SEE IT FOR YOURSELF
Build a transfer call from typed fieldsStep 1 / 4
The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.
The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.Keccak-256 of the canonical signature supplies the first four bytes. The transfer selector is a9059cbb.An address is twenty bytes. Standard ABI encoding adds twelve zero bytes on the left to fill one thirty-two-byte word.The integer one hundred is hex 64, left-padded in word one. Selector plus two words produces sixty-eight bytes of standard calldata.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Fixed bytes have a declared width
bytes1 through bytes32 represent fixed-size byte sequences. bytes4 is often used to describe a function selector. This differs from an integer that happens to contain similar bits.
Dynamic bytes carry variable length
bytes can contain an arbitrary-length sequence within execution and resource limits. Its ABI encoding uses dynamic layout, including length and padding, rather than behaving like every fixed bytes value.
Alignment differs in ABI encoding
A fixed bytes value is right-padded in its word, while an address or unsigned integer is left-padded. Treating all values as interchangeable 32-byte hex strings can therefore decode incorrectly.
Inspect exact byte content
Text encoding and hex display are additional layers. Use the hash tool’s explicit text or hex mode when testing bytes, and keep leading or trailing zeros when they are part of the actual input.
Read the example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract LearningExample {
function echo(bytes calldata data)
external pure returns (bytes memory)
{
return data;
}
}