Skip to main content

EventSignature

An EventSignature is a 32-byte identifier used as the first topic (topic[0]) in Ethereum event logs. It’s computed as the full Keccak-256 hash of the event signature.

Type Definition

Creating Event Signatures

From Signature String

From Hex String

From Bytes

Operations

Convert to Hex

Compare Signatures

Common Event Signatures

ERC-20

ERC-721

Uniswap V2

Event Log Structure

Event signatures appear as the first topic in event logs:

Signature Format

Event signatures must use canonical type names: ✅ Correct:
  • Transfer(address,address,uint256)
  • Swap(address,uint256,uint256,uint256,uint256,address)
  • Deposit(address,(uint256,uint256))
❌ Incorrect:
  • Transfer(address, address, uint256) (has spaces)
  • Transfer(address,address,uint) (should be uint256)
  • transfer(address,address,uint256) (wrong capitalization)
Note: Unlike function signatures, event names conventionally start with uppercase.

How Event Signatures Work

  1. Event Signature: Start with the canonical event signature
  2. Hash: Compute keccak256(signature)
  3. Use Full Hash: Unlike function selectors, use all 32 bytes

Indexed vs Non-Indexed Parameters

Event parameters can be indexed or non-indexed:
The signature does not include the indexed keyword:
  • Signature: Transfer(address,address,uint256)
  • The indexed keyword only affects where data appears in the log

Anonymous Events

Anonymous events don’t include the event signature as topic[0]:
For anonymous events:
  • No topic[0] (no event signature)
  • Indexed params use topic[0], topic[1], topic[2]…
  • Saves gas but harder to identify the event

Filtering Events

Use event signatures to filter logs:

API Reference

Constructors

  • from(value: EventSignatureLike): EventSignatureType - Create from various inputs
  • fromHex(hex: string): EventSignatureType - Create from hex string
  • fromSignature(signature: string): EventSignatureType - Compute from event signature

Operations

  • toHex(sig: EventSignatureType): string - Convert to hex string
  • equals(a: EventSignatureType, b: EventSignatureType): boolean - Compare signatures

See Also