Overview
CallData is a specialized brandedUint8Array that subtypes Hex for representing transaction data. It contains a 4-byte function selector followed by ABI-encoded parameters.
- Type Definition
- Decoded Form
Uint8Array. TypeScript enforces type safety through a unique Symbol brand, preventing accidental mixing with other byte arrays while maintaining zero runtime overhead.Developer Experience
Despite being aUint8Array, calldata displays formatted in most environments:
Quick Start
- Encode Function Call
- Decode CallData
- Extract Selector
Practical Examples
See Fundamentals for detailed explanations of how the EVM processes calldata, function selector derivation, and ABI encoding mechanics.API Methods
Constructors
from(value)- Universal constructor from any inputfromHex(hex)- Parse hex string (with or without 0x prefix)fromBytes(bytes)- Create from Uint8Arrayencode(signature, params)- Encode function call from signature and parameters
Conversions
toHex(calldata)- Convert to hex string with 0x prefixtoBytes(calldata)- Return raw Uint8Arraydecode(calldata, abi)- Decode to CallDataDecoded structure
Selectors
getSelector(calldata)- Extract 4-byte function selectorhasSelector(calldata, selector)- Check if calldata matches selector
Validation
isValid(value)- Check if value can be converted to calldatais(value)- Type guard to check if value is CallData
Comparisons
equals(a, b)- Check equality of two calldata instances
Type Hierarchy
CallData conceptually subtypes Hex but stores asUint8Array internally:
- Type safety: Can’t accidentally pass arbitrary Uint8Array where CallData expected
- Performance: Direct byte manipulation without string conversion
- Interop: Works with Web APIs expecting Uint8Array

