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"))
from toncenter.streaming import (
ActionsNotification,
ActionType,
Finality,
TransactionsNotification,
)
@ws.on_transactions(min_finality=Finality.PENDING)
async def on_tx(n: TransactionsNotification) -> None:
for tx in n.transactions:
print(tx.get("hash"))
@ws.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"))
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
@ws.on_transactions # bare
@ws.on_transactions(min_finality=Finality.CONFIRMED) # with parameters
ws.on_transactions(my_callback, min_finality=...) # programmatic
Event table
| Decorator | Event type | Extra parameters |
|---|
on_transactions() | transactions | min_finality |
on_actions() | actions | min_finality, action_types |
on_traces() | trace | min_finality |
on_account_states() | account_state_change | min_finality |
on_jettons() | jettons_change | min_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.