Function Selector & Event Topic Calculator

Paste a function or event signature to get its selector and topic hash, or paste a selector you found in calldata to see which common function it belongs to.

Parameter names, function, indexed, memory and the returns clause are stripped automatically; uint becomes uint256.

Computed in your browser with JavaScript. Addresses are never uploaded or stored.

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

SignatureSelector
totalSupply()0x18160ddd
balanceOf(address)0x70a08231
transfer(address,uint256)0xa9059cbb
transferFrom(address,address,uint256)0x23b872dd
approve(address,uint256)0x095ea7b3
allowance(address,address)0xdd62ed3e

Common mistakes

Accepted input formats

To build or read full calldata, continue with the ABI encoder / decoder.

Frequently asked questions

What is a function selector?

The first four bytes of the Keccak-256 hash of the canonical function signature: name plus parameter types with no spaces or names, for example transfer(address,uint256) → 0xa9059cbb. The EVM uses it to route a call to the right function.

Why must I use uint256 and not uint?

The canonical signature uses full type names. uint is an alias for uint256 in Solidity, and hashing the alias gives a wrong selector. This tool rewrites uint/int automatically and strips parameter names and data-location keywords.

How are tuples (structs) written?

As parenthesised type lists: exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160)). Write the struct's fields in order; the struct name itself is not part of the signature.

What is an event topic?

The full 32-byte Keccak-256 of the event signature, stored as topics[0] in every log that event emits, for example Transfer(address,address,uint256) → 0xddf252ad…. Indexed parameters become topics[1..3].

How many possible selectors are there?

4 bytes give 232, about 4.3 billion, possible values. With tens of thousands of known signatures collisions are rare but real; within one contract the Solidity compiler refuses two functions with the same selector.

Can two functions share a selector?

Yes, collisions exist because only 4 bytes are used; this is why the lookup can return several signatures and why the EVM cannot tell them apart in the same contract. For unknown selectors use the public databases 4byte.directory and openchain.xyz.