plain.

Keccak-256 online: hashes, selectors and event topics

Hash text or hex bytes with the Keccak-256 that Ethereum uses, turn a function, error or event signature into its selector or topic, or check an address checksum. It works in your browser, so what you paste never leaves this page.

Examples:

Result

Which Keccak this is

Ethereum hashes with the original Keccak-256, the version submitted to the SHA-3 competition. NIST later changed the padding byte when it standardised SHA3-256, so the two give different results for the same input: the Keccak-256 of an empty string is 0xc5d24601…5d85a470, while the NIST SHA3-256 of it begins a7ffc6f8…. If a hash you computed elsewhere doesn’t match, that is the usual reason. This page uses the Ethereum one, which is what Solidity’s keccak256() and ethers.id() compute.

Text is hashed as UTF-8 bytes. In hex mode you paste bytes, with or without 0x, and the hash is of those bytes, the same as keccak256(hex"…"). A text hash and a hex hash of the same bytes agree; hashing the characters 0x1234 as text is a different input from the two bytes 0x1234.

Selectors and topics

The first four bytes of the Keccak-256 hash of a function’s canonical signature are its selector, the start of every call to it, so transfer(address,uint256) gives 0xa9059cbb. Custom errors use the same rule. An event’s topic0 is the whole 32-byte hash of its signature, so Transfer(address,address,uint256) gives 0xddf252ad…3ef. This is why you will see the same hash start a log and a selector start a call.

The canonical signature has no spaces, no argument names, no indexed, and spells uint as uint256 and tuples as (address,uint256). You don’t have to write it that way: paste function transfer(address to, uint256 amount) returns (bool) or event Transfer(address indexed from, address indexed to, uint256 value), one per line, and the tool shows the canonical form it hashed along with the selector and the full hash. Types are checked, so a typo such as uint257 is reported instead of hashed.

Address checksums

An EIP-55 checksum writes the letters of an address in upper or lower case according to the Keccak-256 of its lowercase hex, which lets a wallet catch most typos. Paste an address and the tool shows the checksummed form. If you pasted mixed case and it doesn’t match, the tool says so, which means a character is wrong or the case was changed. An address in all lowercase or all uppercase carries no checksum to check, so it is shown with the correct one. The reference example 0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed from the EIP checks out.

Where it stops

  • It computes Keccak-256 only, not SHA3-256, Keccak-512 or abi.encodePacked of several values. To hash the packed encoding of several values, encode them yourself and paste the result in hex mode.
  • It doesn’t look a selector up in a signature database, so it can’t tell you which function 0xa9059cbb is; for the reverse you need a database such as 4byte, and the ABI tool on this site decodes calldata when you already know the signature.
  • Signatures are read as human-readable text. Event items in a JSON ABI aren’t read; paste the event as a line.
  • It runs in your browser with no network request for what you paste, and nothing is stored. It is a plain JavaScript implementation, checked against independent implementations for empty input, a 135-, 136- and 137-byte input (around the block size) and a long input.

Working on Solidity?

plain is one small, MIT-licensed binary that compiles, tests, deploys, verifies and upgrades Solidity contracts, and runs Foundry projects as they are. Its builds write each contract’s methodIdentifiers, the selectors this page computes by hand.

See what plain does