Try it Live
Run ABI examples in the interactive playground
Conceptual guide - For encoding rules, see ABI Encoding.
Overview
Selectors identify functions, events, and errors in Ethereum. They are derived from canonical signatures using keccak256.Quick Start
- Function
- Event
- Error
Canonical Signatures
Signatures are generated from the canonical type list:- No whitespace
- Use full size types (
uint256,int256) - Tuples use parentheses:
foo((uint256,address)) - Arrays include brackets:
foo(address[])
Event Topic0 and Anonymous Events
Non-anonymous events includetopic0 = keccak256(signature). Anonymous events omit topic0 entirely, so all topics are indexed parameters only.
Selector Collisions
Function selectors are 4 bytes, so collisions are possible. You can scan an ABI for collisions:Common Selectors
ERC-20 functions: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)

