Try it Live
Run ABI examples in the interactive playground
Overview
Selectors identify functions, events, and errors in Ethereum. Generated from human-readable signatures using keccak256 hashing.Function Selectors
Function selector: First 4 bytes ofkeccak256(signature)
uint256 not uint)
Event Selectors
Event selector: Full 32 bytes ofkeccak256(signature) (topic0)
Error Selectors
Error selector: First 4 bytes ofkeccak256(signature) (same as functions)
Signature Generation
Signatures represent function/event/error in canonical form.Canonical Type Names
Types must use canonical names for correct selectors:- ✅
uint256,int256(explicit size) - ❌
uint,int(implicit size - invalid) - ✅
bytes32(fixed-size bytes) - ✅
bytes(dynamic bytes) - ✅
address(20 bytes) - ✅
bool(1 byte)
Tuple Signatures
Tuples (structs) expand into signature:Array Signatures
Arrays include brackets in signature:Selector Collisions
4-byte function selectors can collide (birthday paradox). ~77,000 functions → 50% collision chance. Event selectors (32 bytes) have negligible collision risk.Standard Selectors
Common function selectors:0xa9059cbb-transfer(address,uint256)0x23b872dd-transferFrom(address,address,uint256)0x095ea7b3-approve(address,uint256)0x70a08231-balanceOf(address)
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef-Transfer(address,address,uint256)0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925-Approval(address,address,uint256)
Custom Hash Functions
Use factories for custom keccak256 implementations:See Also
- Function getSelector - Get function selector
- Event getSelector - Get event selector
- Encoding - ABI encoding mechanics

