Function Signature
1 min read
Pronunciation
[fungk-shun sig-nuh-cher]
Analogy
A function signature is like a phone extension number—callers dial it to reach the correct department (function).
Definition
The textual representation `name(type1,type2,…)` of a contract function, whose first 4 bytes of its Keccak‑256 hash form the selector used in calldata dispatch.
Key Points Intro
Function signatures route calls via:
Key Points
Selector: First 4 bytes of `keccak256(signature)` in calldata.
Encoding: Followed by ABI‑encoded arguments.
Collision risk: Rare but possible if different signatures share first 4 bytes.
Dispatcher: EVM uses selector to jump to function implementation.
Example
The signature `transfer(address,uint256)` hashes to `0xa9059cbb…`, so calldata begins with `0xa9059cbb`.
Technical Deep Dive
Solidity’s fallback dispatcher reads the first 4 bytes, compares against known selectors in a jump‑table, and invokes the matched function. Unmatched selectors trigger `fallback()`. Collisions require careful interface design or manual selector management.
Security Warning
Selector collisions can be exploited to invoke unintended functions; avoid overloaded functions with same signature fragments.
Caveat
Manual selector handling is error‑prone; rely on compiler‑generated tables when possible.
Function Signature - Related Articles
No related articles for this term.