Skip to main content

Try it Live

Run EventLog examples in the interactive playground
Conceptual Guide - For API reference and method documentation, see EventLog API.
Ethereum event logs are structured outputs emitted by smart contracts during execution. They enable efficient off-chain indexing and querying of on-chain activity without scanning all transaction data.

Structure

An event log contains:
  • Address - Contract that emitted the log (20 bytes)
  • Topics - Up to 4 indexed parameters (32 bytes each)
  • Data - Non-indexed parameters (variable length)
  • Metadata - Block number, transaction hash, log index

Topics and Indexed Parameters

Topics enable efficient log filtering via bloom filters. The first topic (topic0) is the event signature hash:
This compiles to:
  • topic0 - keccak256("Transfer(address,address,uint256)")
  • topic1 - from address (padded to 32 bytes)
  • topic2 - to address (padded to 32 bytes)
  • data - value (not indexed, in log data field)

Creating and Parsing Event Logs

Event Signature Hashing

Event signatures are computed by hashing the canonical event declaration:
Event signatures must use canonical types: uint256 (not uint), address (20 bytes), no spaces. Incorrect signatures will not match emitted events.

Filtering Event Logs

Address Filtering

Topic Filtering

Complete Filter

Bloom Filters in Block Headers

Block headers contain a 2048-bit bloom filter enabling efficient log queries without scanning all transactions.

How Bloom Filters Work

  1. For each log, hash the address and each topic
  2. Set 3 bits in the bloom filter per hash
  3. To query: check if all required bits are set
  4. False positives possible, false negatives impossible
See BloomFilter documentation for details.

ABI Decoding Integration

Event data requires ABI decoding for non-indexed parameters:

Anonymous Events

Anonymous events omit the signature hash (topic0), allowing 4 indexed parameters instead of 3:
This produces:
  • topic0 - from (first indexed parameter, NOT signature)
  • topic1 - to
  • topic2 - tokenId
  • topic3 - price
  • data - Empty (all parameters indexed)

Complete Example: ERC-20 Transfer Tracking

Chain Reorganizations

Logs can be marked as removed: true when chain reorganizations invalidate their blocks:

Performance Considerations

Bloom Filter False Positives

Bloom filters enable fast queries but produce false positives (10-20% typical):

Efficient Filtering

Resources

Next Steps