/ Docs
7.3
/

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

dipdup.yaml
spec_version: 2.0
package: demo_events

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

contracts:
  events_contract:
    kind: tezos
    address: KT1Up6AMehze2VTdt3w85xaZPtrEWn1AeyR3

indexes:
  events:
    kind: tezos.tzkt.events
    datasource: 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_events import models as models
from demo_events.types.events_contract.tezos_events.move import MovePayload
from dipdup.context import HandlerContext
from dipdup.models.tezos_tzkt import TzktEvent


async def on_move_event(
    ctx: HandlerContext,
    event: TzktEvent[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_events import models as models
from dipdup.context import HandlerContext
from dipdup.models.tezos_tzkt import TzktUnknownEvent


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