What is a function selector?
A function selector is the first 4 bytes of the Keccak-256 hash of a function's canonical signature: the name followed by the parameter types in parentheses with no spaces or names, for example transfer(address,uint256) → 0xa9059cbb. It forms the first 4 bytes of every contract call's calldata and tells the contract which function to run; the remaining bytes are the ABI-encoded arguments.
Common selectors
The table is computed on this page with the same Keccak implementation used by the tool, so it doubles as a self-test. Paste any selector into the box above to look it up.
Worked example
Take function approve(address spender, uint256 amount) external returns (bool). Strip the keyword, parameter names, visibility and return type to get approve(address,uint256). Keccak-256 of that ASCII string starts 0x095ea7b3…, so the selector is 0x095ea7b3. The calldata for approving 1 USDT (6 decimals) is the selector, the spender address left-padded to 32 bytes, and 1000000 as a 32-byte word: 4 + 32 + 32 = 68 bytes.
ERC-20 selectors you will see most
| Signature | Selector |
|---|---|
totalSupply() | 0x18160ddd |
balanceOf(address) | 0x70a08231 |
transfer(address,uint256) | 0xa9059cbb |
transferFrom(address,address,uint256) | 0x23b872dd |
approve(address,uint256) | 0x095ea7b3 |
allowance(address,address) | 0xdd62ed3e |
Common mistakes
- Hashing
uintinstead ofuint256.transfer(address,uint)hashes to a different value; the canonical form always spells out the width. - Including parameter names or spaces.
transfer(address to, uint256 amount)is not a canonical signature. - Using the struct name for tuples. Structs are written as their field types in parentheses, never as
MyStruct. - Confusing selector and topic. Functions use 4 bytes; events use the full 32-byte hash.
Accepted input formats
transfer(address,uint256): canonical form.function transfer(address to, uint256 amount) external returns (bool): Solidity declaration; names, visibility and returns are removed.event Transfer(address indexed from, address indexed to, uint256 value): theindexedkeyword is ignored for the topic hash.0xa9059cbbor a 32-byte topic: reverse lookup against the built-in list.
To build or read full calldata, continue with the ABI encoder / decoder.