UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

About·Changelog·Privacy Policy·Terms of Service·Contact
HomeSmart Contracts & EVMFunction Selector

Related Tools

Gas Fee CalculatorENS NamehashEIP-712 HashMerkle Tree BuilderABI EncoderChain ID ReferenceETH Tx Decoder

Solidity Function Selector Calculator

Get the 4-byte Ethereum function selector for any Solidity signature, e.g. transfer(address,uint256) → 0xa9059cbb. Keccak-256, runs in your browser.

You Might Also Like

All Smart Contracts & EVM

Keccak-256

Compute the Keccak-256 hash of text or raw hex bytes entirely in your browser — the Ethereum variant, not NIST SHA-3. No uploads, ever.

Gas Fee Calculator

How much will an Ethereum transaction cost? Enter gas units and fees to get the cost in Gwei, ETH and USD, in EIP-1559 or legacy mode, with 6 presets.

Token Supply

Convert ERC-20 token amounts to raw base units and back for any decimals value, e.g. 1.5 at 18 decimals → 1500000000000000000. BigInt-exact, in-browser.

APY/APR Converter

Convert APY to APR or APR to APY across 8 compounding frequencies. Shows the formula, result, and a full comparison table. Includes continuous compounding.

Every call to an Ethereum contract starts with 4 bytes that say which function is being invoked, and those 4 bytes aren’t looked up anywhere. They’re computed: the first 4 bytes of Keccak-256 over the function’s canonical signature. Function Selector Calculator computes that directly. The Web Crypto API ships SHA-3, not Keccak, and the two use different padding and produce different digests, so this implements Keccak-f[1600] from scratch rather than reaching for a primitive that would quietly give the wrong answer.

Reach for it when a transaction is reverting and you want to confirm the selector your frontend is sending matches the one the contract expects, or when you’re reading raw calldata and need to know what function it’s calling before decoding the rest. Paste a signature, with or without parameter names, and the selector appears immediately. Going the other way, from a 4-byte selector found in calldata back to a function, is only possible against a list of known signatures, because the hash can’t be reversed: paste 0xf8b2cb4f and the tool answers getBalance(address) from its list of 45 common functions, or links the selector to the 4byte.directory database when it isn’t one of them.

A Real Example: transfer’s Selector

Paste transfer(address to, uint256 amount), a signature the way you’d actually see it in Solidity source with parameter names included, and the tool strips those names down to transfer(address,uint256) before hashing, shown above the result as Canonical form. That hashes to 0xa9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b, and the first 4 bytes, 0xa9059cbb, are the selector that shows up in the calldata of every ERC-20 transfer ever sent.

The Algorithm Behind Every Selector

Keccak-256 runs 24 rounds of a permutation over a 1600-bit state, absorbing the signature 136 bytes at a time and producing a 32-byte digest; the selector is simply that digest’s first 4 bytes, hex-encoded. This implementation was checked during development against reference digests for the empty string, several real ERC-20 and ERC-721 selectors, and the padding edge cases at exactly one block and one byte short of a block, and it matched every one exactly.

What It Accepts: Names, Types and Tuples

  • A whole declaration copied from Solidity source works: function balanceOf(address account) public view returns (uint256); gives 0x70a08231. The function, event or error keyword, the modifiers and the returns part are dropped, as are memory, calldata, indexed and payable.
  • Short type names are expanded before hashing, because the selector is taken over the canonical ABI form: uint becomes uint256, int becomes int256 and byte becomes bytes1. Hashing transfer(address,uint) as written would give 0x6cb927d8, not the real 0xa9059cbb.
  • Contract, interface, enum and struct names aren’t ABI types. deposit(IERC20 token, uint256 amount) stops with “‘IERC20’ isn’t an ABI type, so it can’t be hashed as written.” Write address for a contract, uint8 for an enum and a tuple for a struct.
  • For an event, the full 32-byte hash is the log’s topic 0, so Transfer(address,address,uint256) gives 0xddf252ad…; the 4-byte part is only used for functions and custom errors.
  • Standard types and array suffixes parse cleanly — address[], uint256[3], bytes32 all canonicalise correctly, with or without a trailing parameter name.
  • Unnamed tuple parameters work too, nesting included — foo((uint256,address),bytes) canonicalises exactly as typed, since that already is the ABI-canonical tuple form.
  • A tuple with named inner fields, like (uint256 a, address b) data, can’t be safely stripped down to its type automatically — the tool shows “Can’t safely strip a named field inside a tuple parameter” rather than silently guessing and risking a wrong selector. Remove the inner names before pasting.

Selector (4 bytes)

0xa9059cbb

Full Keccak-256

0xa9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b

Paste a signature with or without parameter names, or a whole line from Solidity source — function transfer(address to, uint amount) external returns (bool); and transfer(address,uint256) hash to the same selector, since names are stripped and uint becomes uint256 before hashing. Paste a selector like 0xa9059cbb to look it up. Structs must be written as tuples, such as (uint256,address), without inner names.