Ethereum Function Selector Calculator
Compute the four-byte function selector and the full event topic hash for any Solidity signature, with the canonical form shown and the collisions and mistakes that break calldata explained.
Last reviewed by the Radiatus Cloud team
Need this done properly for your business?
Radiatus delivers secure cloud, DevOps & compliance engineering.
The selector is the first four bytes of the keccak hash of a canonical signature
A contract call is dispatched on four bytes derived from the function name and its parameter types, and nothing else: not the parameter names, not the return type, not the visibility or mutability keywords. Getting the canonical form wrong is the most common reason a hand-built call reverts with no useful error, because the contract simply finds no matching selector and falls through to its fallback function or fails outright. The canonical form uses the base type names, so uint must be written uint256 and the whole signature carries no spaces.
Four bytes is small enough for collisions to be findable
Four bytes is 32 bits, so a birthday collision is reachable with about 65,000 candidate signatures, and finding a specific collision with a chosen selector takes minutes of ordinary compute. This is why a proxy contract that dispatches on a selector can be made to route a call somewhere unintended, and why the Solidity compiler rejects two functions in the same contract whose selectors collide. It is a real consideration in proxy and diamond patterns rather than a theoretical one.
Events use the whole hash, not four bytes
An event's topic zero is the full 32-byte keccak hash of its signature, which is why event topics do not collide in practice. The other topics are the indexed parameters, and only up to three may be indexed for a non-anonymous event. A common mistake when filtering logs is to compute a four-byte selector for an event and find nothing, because the topic is the full hash.
Related tools
- Ethereum Unit Converter — Convert between Wei, Gwei, and Ether units.
- Gas Fee Calculator — Calculate transaction costs based on gas price and limit.
- IPFS CID Generator — Generate IPFS Content Identifiers (CID) from text or files.
- Wallet Address Validator — Validate Ethereum and Bitcoin wallet addresses.
Frequently Asked Questions
What goes into the canonical signature?
The function name and the base parameter types, with no spaces, no parameter names, no return type and no keywords. uint must be written as uint256 and address payable as address.
Why does my call revert with no message?
Very often because the selector does not match anything on the contract, so the call falls through to the fallback function or fails outright. Check the canonical form before checking anything else.
Can two functions share a selector?
Yes. Four bytes is 32 bits, so a collision is findable with modest compute, which is why Solidity rejects colliding selectors within one contract and why proxy patterns have to consider it.
How do I filter for an event?
Use the full 32-byte keccak hash of the event signature as topic zero, not a four-byte selector. Computing four bytes for an event and finding no logs is a common mistake.
How are structs and arrays written?
A struct is written as a parenthesised tuple of its member types, and arrays keep their brackets, so a function taking a struct of two uint256 values is name((uint256,uint256)).
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Enter Solidity function or event signatures to compute their selectors.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.