Skip to main content

Try it Live

Run ABI examples in the interactive playground

Overview

ABI encoding serializes typed data into byte sequences for EVM consumption. Solidity ABI specification defines encoding rules for all Ethereum types.

Encoding Rules

Static types (fixed size):
  • uint<N>, int<N>, address, bool, bytes<N> (N ≤ 32)
  • Encoded in-place as 32-byte words
Dynamic types (variable size):
  • bytes, string, arrays (T[], T[k])
  • Encoded with offset pointer + length + data

Function Encoding

Function calls encode as: selector (4 bytes) + params (ABI-encoded)

Event Encoding

Events encode indexed parameters as topics, non-indexed as data.
Topic limits: Max 3 indexed parameters (topic0 is selector)

Error Encoding

Errors encode like functions: selector (4 bytes) + params

Constructor Encoding

Constructor parameters append to contract bytecode during deployment.

Tuple Encoding

Tuples (structs) encode components sequentially.

Array Encoding

Fixed-size arrays: Encode elements sequentially Dynamic arrays: Encode length + elements

Packed Encoding

Standard ABI uses 32-byte words. Packed encoding removes padding (used in abi.encodePacked for signatures/hashing). Tevm uses standard ABI encoding. For packed encoding, use manual byte manipulation.

Decoding

Decoding reverses encoding process, extracting typed values from byte sequences.

Specification

Full encoding rules: Solidity ABI Specification

See Also