Solidity Function Selector & Event Topic0 Calculator
Turn Solidity function, event, and custom-error signatures into 4-byte EVM selectors and 32-byte Keccak-256 topic0 hashes. Everything runs locally in your browser.
Accepts function/event/error declarations, parameter names, visibility modifiers, and Solidity type aliases.
Parameter names are stripped automatically so copied source declarations hash to the same canonical signature.
Load an example set
Computed selectors & topic0 hashes
A selector is keccak256(canonicalSignature)[0..4]; an event topic0 is the full 32-byte hash. Selector collisions are flagged automatically. Keccak-256 here is Ethereum’s pre-NIST variant, not SHA3-256.
Frequently asked questions
What is the difference between a function selector and an event topic0?
A function or custom-error selector is the first 4 bytes of keccak256 over its canonical signature, such as transfer(address,uint256) → 0xa9059cbb. An event topic0 is the full 32-byte hash of the event signature, such as Transfer(address,address,uint256) → 0xddf252ad…b3ef. This calculator shows both values for every line so you can use either form.
Do parameter names and the indexed keyword change the hash?
No. Canonical signatures contain only the function or event name and its ABI types. With “Canonicalize types” enabled, this tool strips parameter names, visibility and data-location keywords, and event indexed markers, then normalizes aliases such as uint → uint256 and byte → bytes1. Uncheck it to keep parameter names in the hashed text; ABI-only keywords are still removed.