Beginner
Understanding the ABI — Key concepts
Demystify the ABI.
Developer Beginner
3/7 — Understanding the ABI — Key concepts
Function signaturekeccak256("transfer(address,uint256)") → first 4 bytes = selector. Parameter order and types must match exactly.
Trusted third parties are security holes.
EncodingABI encoding packs static types (uint256, address, bool) and offsets to dynamic types (strings, bytes, arrays). Misordered args = bad decode.
OverloadsTwo functions can share a name with different types; their selectors differ. Overuse can confuse integrators—avoid unless necessary.
EventsEvent signature is keccak of the event declaration; indexed params go to topics, others to data. Changing any type changes the signature.
// Signature → selector (4 bytes)
// transfer(address,uint256) → 0xa9059cbb
function transfer(address to, uint256 amount) external returns (bool);
Selector formula
selector = first4Bytes( keccak256("functionName(type1,type2,...)") )