event index

Kathmandu Tezos protocol upgrade has introduced contract events, a new way to interact with smart contracts. This index allows indexing events using strictly typed payloads. From the developer's perspective, it's similar to the big_map index with a few differences.

An example below is artificial since no known contracts in mainnet are currently using events.

indexes:
  events:
    kind: event
    datasource: tzkt
    handlers:
      - callback: on_events_xrate
        contract: events
        tag: xrate
      - callback: on_events_unknown
        contract: events

Unlike big maps, contracts may introduce new event tags and payloads at any time, so the index must be updated accordingly.

async def on_events_xrate(
    ctx: HandlerContext,
    event: Event[XratePayload],
) -> None:
    ...

Each contract can have a fallback handler called for all unknown events so you can process untyped data.

async def on_events_unknown(
    ctx: HandlerContext,
    event: UnknownEvent,
) -> None:
    ...