UtilityToolsLab

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

Free eBooks·About·Changelog·Privacy Policy·Terms of Service·Report a bug
HomeSmart Contracts & EVMFunction Selector

Related Tools

Gas Fee CalculatorENS NamehashMerkle Tree BuilderABI Encoder

Function Selector (4-byte) Calculator

Compute the 4-byte Ethereum function selector from a Solidity signature using Keccak-256, entirely in your browser. Paste names or types.

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

Calculate Ethereum gas fees in ETH and USD. Supports EIP-1559 (base fee + tip) and legacy gas price. Six transaction type presets included.

ENS Namehash

Compute the ENS namehash (EIP-137) for any .eth domain, label by label, using Keccak-256 in your browser. See every recursive hashing step.

Merkle Tree Builder

Build a Keccak-256 Merkle tree from an address allowlist, read off the root, and copy an inclusion proof for any leaf. OpenZeppelin sorted pairs.

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.

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

  • 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 — transfer(address to, uint256 amount) and transfer(address,uint256) hash to the same selector, since the names are stripped before hashing. Tuple and struct parameters aren’t canonicalised; paste those already in their fully qualified form.