tezos.events 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 tezos.big_maps index with a few differences.

dipdup.yaml
spec_version: 3.0
package: demo_tezos_events

datasources:
  tzkt:
    kind: tezos.tzkt
    url: https://api.ghostnet.tzkt.io

contracts:
  events_contract:
    kind: tezos
    address: KT1Up6AMehze2VTdt3w85xaZPtrEWn1AeyR3

indexes:
  events:
    kind: tezos.events
    datasources:
      - tzkt
    handlers:
      - callback: on_move_event
        contract: events_contract
        tag: move
      - callback: on_roll_event
        contract: events_contract
        tag: roll
      - callback: on_other_event
        contract: events_contract

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

handlers/on_move_event.py
from demo_tezos_events import models as models
from demo_tezos_events.types.events_contract.tezos_events.move import MovePayload
from dipdup.context import HandlerContext
from dipdup.models.tezos import TezosEvent


async def on_move_event(
    ctx: HandlerContext,
    event: TezosEvent[MovePayload],
) -> None: ...

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

handlers/on_other_event.py
from demo_tezos_events import models as models
from dipdup.context import HandlerContext
from dipdup.models.tezos import TezosUnknownEvent


async def on_other_event(
    ctx: HandlerContext,
    event: TezosUnknownEvent,
) -> None: ...
Help and tips -> Join our Discord
Ideas or suggestions -> Issue Tracker
GraphQL IDE -> Open Playground