Transaction Tracking
Tracking the status of cross-chain transactions is essential for providing a good user experience in hybrid dApps. The TAC SDK provides robust tools for monitoring the progress of transactions across both TON and TAC EVM chains.
Cross-chain transactions go through multiple stages across different blockchains. The TAC SDK’s tracking tools help you monitor this process and provide appropriate feedback to users.
Understanding Transaction Flow
When a cross-chain transaction is initiated, it passes through several stages:
- TON Side: Transaction is sent from the user’s TON wallet
- Sequencer Network: Transaction is collected, validated, and included in Merkle trees
- TAC EVM Side: Transaction is executed on the target EVM contract
- Return Path: Results and/or assets may be sent back to TON
Creating a Transaction Tracker
To track transactions, you’ll use the OperationTracker class:
Getting the Operation ID
The first step in tracking a transaction is to get its operation ID using the TransactionLinker object that was returned when sending the transaction:
An empty response when calling getOperationId
means the sequencers haven’t yet received or processed your transaction. You should implement a retry mechanism with appropriate delay.
Checking Transaction Status
Once you have the operation ID, you can check the transaction’s status:
Understanding Status Stages
The transaction can be in one of these stages, represented by the StageName enum:
Stage | Description |
---|---|
COLLECTED_IN_TAC | The sequencer has collected events for a sharded message |
INCLUDED_IN_TAC_CONSENSUS | The EVM message has been added to the Merkle tree |
EXECUTED_IN_TAC | The message has been executed on the EVM side |
COLLECTED_IN_TON | A return message event has been generated for TON execution |
INCLUDED_IN_TON_CONSENSUS | The TON message has been added to the Merkle tree |
EXECUTED_IN_TON | The message has been executed on the TON side (terminal state) |
Getting Simplified Status
For a simpler status representation, use the getSimplifiedOperationStatus
method:
Getting Operation Type
You can also get the type of operation, which provides more context about the transaction flow:
Automatic Transaction Tracking
For a more convenient approach, you can use the startTracking
function to automatically track a transaction until completion:
Advanced Tracking Features
Getting Performance Data
You can get performance data for a transaction to understand how long each stage took:
Multiple Operations Tracking
If you need to track multiple operations at once:
Implementing a Complete Tracking System
Here’s a complete example of a tracking system with retries:
Was this page helpful?