Tool · runs in your browser

Event signature to topic0, and function selector calculator

Paste an event or a function signature, with or without parameter names and indexed, and get the canonical signature, its keccak-256 hash (an event's topic0) and its first four bytes (a function's selector). Paste a topic0 or a selector instead to see whether it is an event or method the app already knows.

Signature, topic0 or selector
Names, indexed and spaces are fine: the tool builds the canonical form.
Try:
How to use it

How to use it

  1. 1Paste a signature, e.g. Transfer(address indexed from, address indexed to, uint256 value), or a topic0 or 4-byte selector.
  2. 2Read the canonical signature, the topic0 and the selector. Copy any of them with one click.
  3. 3If the event is in our catalog, open its page or a ready-made rule that alerts you when a contract emits it.
Explained

What is topic0?

Every log a contract emits carries up to four 32-byte topics. For a normal (non-anonymous) event, the first one, topic0, is the keccak-256 hash of the event's canonical signature: its name and parameter types, with no spaces, no parameter names and no indexed keyword.

That is why Transfer(address indexed from, address indexed to, uint256 value) and Transfer(address,address,uint256) have the same topic0, and why ERC-20 and ERC-721 Transfer events share it even though they index different parameters. Explorers, indexers and alert rules all filter logs by topic0.

Explained

What is a function selector?

A function selector is the first four bytes of the keccak-256 hash of a function's canonical signature. It is the first thing in a transaction's input data and tells the contract which function to run; the encoded arguments follow it.

Because only four bytes are kept, different signatures can share a selector. A selector tells you which function was probably called; the full signature, or the contract's ABI, tells you for sure.

Explained

How the canonical signature is built

The hash is only right when the signature is exactly what the compiler hashes. The tool normalises it for you:

  • Parameter names, indexed, memory, calldata and spaces are dropped.
  • uint and int become uint256 and int256.
  • Structs become tuples of their member types, e.g. (address,uint256)[] for an array of structs.
  • The function or event keyword and any returns clause are ignored.
FAQ

Frequently asked questions

Is topic0 the same as the event signature hash?

Yes, for every event that isn't declared anonymous: topic0 is keccak256 of the canonical signature. An anonymous event has no topic0, so its logs can only be matched by address and its indexed arguments.

Why does my selector not match the one in the transaction?

Usually a type is spelled differently: uint instead of uint256, a struct instead of its tuple, or a missing parameter. Paste the declaration exactly as the contract has it and the tool builds the canonical form.

Can I find the signature for an unknown topic0?

Only if it is in our catalog of standard events, which the tool checks. A hash can't be reversed; signature databases work by hashing known signatures and storing the results.

Is what I paste sent anywhere?

No. The tool runs entirely in your browser: what you paste is never sent to a server and there is no sign-up.

How do I get an alert when a contract emits this event?

Open a ready-made rule from the result: the events the app knows link to rules with the contract and the conditions filled in. Sign in, pick your chat and click Create.

Keep exploring

More tools and alerts

Know the moment it happens on chain

Turn any event into an alert. The Beta plan is free: one wallet and one contract, no credit card.