The TON Streaming API provides critical real-time access to events on the TON blockchain, but the meaning of those events—especially their "finality"—directly impacts how developers, users, and decentralized applications interact with TON. Proper understanding and implementation of finality status are essential for security, reliability, and user trust within TON’s growing ecosystem.
TON Streaming API: Event Finality Breakdown
When using the TON Streaming API, applications receive live notifications regarding blockchain transactions as they occur. Trace-based events include a finality tag indicating whether a result is speculative, included in a candidate shard block, or committed in the masterchain. Account and jetton state-change events are emitted at confirmed or finalized levels. Understanding these tags—and acting appropriately upon them—is vital for anyone building or integrating with TON-based services.
The three finality states are:
- Pending: The streaming trace is based on emulation or speculative execution, not a finalized on-chain transaction. Such a trace may be invalidated by a later trace_invalidated event.
- Confirmed: The trace or its transactions have reached a candidate shard block. Rollback probability is very small, but final masterchain commitment has not yet been reached.
- Finalized: The trace is committed in the masterchain; the Streaming API documentation states that a finalized trace will not be updated or invalidated.
These distinctions aren’t merely academic. For developers and product teams building wallets, DeFi protocols, swaps, cross-chain bridges, and notification platforms, recognizing and acting on finality status helps avoid errors, reduce security risks, and deliver a trustworthy user experience. The difference between “confirmed” and “finalized” can be the difference between an accurate balance and a lost or duplicated asset.
More technical details and definitions about these event statuses can be found in the official TON Streaming API documentation.
Managing Transaction States in Applications
It is tempting to immediately act when a transaction appears in the stream—such as crediting user balances, unlocking assets, or displaying payment confirmations. However, as reinforced by TON’s own documentation and community best practices, sensitive operations must wait until the transaction reaches the "finalized" state. Doing so helps protect users from rare but impactful blockchain reorganizations, where "confirmed" transactions might be invalidated or reordered.
If applications wish to improve user experience by alerting users when a transaction is "pending" or "confirmed," it’s imperative to make clear that these statuses are provisional. Visual indicators such as labels ("Pending," "Awaiting finality") or warnings can signal to users that changes are still possible. In the background, application logic should continue monitoring the transaction status and only make permanent state changes when finalization occurs.
For robust integration:
- Delay irreversible actions—such as unlocking tokens for DeFi contracts or allowing withdrawals—until the TON Streaming API event switches to "finalized."
- Implement logic to revert or adjust previously issued notifications if provisional transactions are dropped or reversed before finality.
- Test workflows across all states, ensuring apps handle edge cases when events revert from "confirmed" back to "pending," or are removed due to fork rollbacks.
These precautions help protect both user funds and application integrity—particularly vital when building trust-minimized features like swaps, lending, or trading interfaces.
For those interested in deeper integrations—ranging from DeFi platforms to analytics tools—see the expanding ecosystem at TON tools and DeFi.
Guidelines for Developers and Users
For Developers: Subscribe to the minimum finality level your application requires. For irreversible actions, use finalized trace-based events and independently verify the on-chain transaction. Reconcile gaps with the indexed API v3 after disconnects or restarts; streaming updates alone do not guarantee complete event history. Handle trace_invalidated notifications for provisional traces.
For Users:
- Understand that wallet and dApp notifications marked as "pending" or "confirmed" are not always permanent. Double-check before considering a transaction complete.
- Be cautious about acting—especially for high-value transfers or trades—until applications display a "finalized" status.
- Inspect wallet prompts carefully, avoid approving multiple conflicting requests, and search for verification of finality in transaction histories before considering your action successful.
—
