Skip to main content
Multiple handlers on the same event type run sequentially in registration order.
from toncenter.streaming import (
    ActionsNotification,
    ActionType,
    Finality,
    TransactionsNotification,
)


@sse.on_transactions(min_finality=Finality.PENDING)
async def on_tx(n: TransactionsNotification) -> None:
    for tx in n.transactions:
        print(tx.get("hash"))


@sse.on_actions(
    min_finality=Finality.FINALIZED,
    action_types=[ActionType.JETTON_TRANSFER, ActionType.TON_TRANSFER],
)
async def on_action(n: ActionsNotification) -> None:
    for a in n.actions:
        print(a.get("type"))

Decorator forms

Three forms are supported:
@sse.on_transactions                                       # bare
@sse.on_transactions(min_finality=Finality.CONFIRMED)      # with parameters
sse.on_transactions(my_callback, min_finality=...)         # programmatic

Event table

DecoratorEvent typeExtra parameters
on_transactions()transactionsmin_finality
on_actions()actionsmin_finality, action_types
on_traces()tracemin_finality
on_account_states()account_state_changemin_finality
on_jettons()jettons_changemin_finality
on_trace_invalidated()trace_invalidated

on_trace_invalidated

Fires when a previously delivered pending or confirmed trace becomes invalid. Discard cached data for that trace.
from toncenter.streaming import TraceInvalidatedNotification


@sse.on_trace_invalidated
async def on_invalidated(n: TraceInvalidatedNotification) -> None:
    print(f"Trace invalidated: {n.trace_external_hash_norm}")
An exception inside a handler halts dispatch for that notification (fail-fast).
See Events for finality levels, notification models, and action types.