Skip to main content

Question it answers

“Give me every raw event log of signature T (topic0), chain-wide, in on-chain order.”
The by-event-type mirror of Contract Logs, the same raw-log extraction, but keyed by the event signature (topic0) instead of the emitting contract. Use it to index one event across all contracts: every Transfer, every Approval, every Uniswap Swap, typically scoped to a block range.

What you get

One row per log, keyed by event signature. Same columns as Contract Logs, topic0…topic3, data, contract_address, tx_hash, and the (block_number, transaction_index, log_index) ordering tuple, but topic0 leads the sort key so a chain-wide “all logs of this signature” read is a contiguous range.

On-chain ordering

Every destination is keyed topic0 first, then the on-chain tuple:
  • ClickHouse: ORDER BY (chain_id, topic0, block_number, transaction_index, log_index, …). topic0 is low cardinality (one value per signature), so it’s a cheap, highly selective leading key.
  • Postgres / MySQL: a composite index on (topic0, block_number, transaction_index, log_index); WHERE topic0 = T AND block_number BETWEEN … ORDER BY … is answered by an index range scan with no filesort.
Logs with an empty topic0 (anonymous events) are filtered out, they have no signature to key on.

Optional: scope to a contract (topic0 + contract)

The primary key leads with topic0, so “all Transfer logs emitted by contract X” prefix-scans to the signature and filters contract_address within it. Because a popular signature (Transfer, Approval) spans millions of contracts, an opt-in (topic0, contract_address, …) structure makes that read a tight (topic0, contract) range that stays sort-free and skips the signature’s other contracts. Shipped commented-out in each schema:

Destination

Same source and reorg model as Contract Logs (raw block array → itemType = 'log', tx_hash recovered from the sibling transaction row; immutable append-only logs in a collapsing table).

Full schema

Identical columns to Contract Logs, the only difference is the sort key leads with topic0. Keep the columns you need (see Schema & flexibility).
Postgres / MySQL mirror this as a flat topic_logs table keyed (topic0, block_number, transaction_index, log_index), with the optional (topic0, contract_address, …) index commented out.

Example reads

All logs of an event signature in a block range, in on-chain order (ClickHouse):

Modes

Shipped defaults: ClickHouse hybrid, Postgres / MySQL historical. For live/reorg-safe ingestion use ClickHouse.
A topic0-keyed sync is heavy for popular signatures, Transfer and Approval span the whole chain. Scope reads to a block range, and for chain-heavy backfills run the ClickHouse path.

EVM only

Like Contract Logs, this extracts EVM event logs (topic0…3 + data); Solana program logs are a different model.

Contract Logs

The sibling, every log from one contract, keyed by emitter.

Onchain Event Indexing

The use case these raw-log recipes power.