It continuously polls the blockchain for the latest transaction and balance of a given wallet address, and alerts when new transactions are detected. This recipe is useful for:
- Building bots that notify users of incoming/outgoing payments
- Tracking balances for custodial or exchange wallets
- Exploring and debugging account activity in real time
The examples use the public Ton Center endpoint:For production, you should request your own API key and use a dedicated endpoint for higher rate limits and stability.
1. Fetching transactions
Transactions for an account can be retrieved via thegetTransactions
method.
Example request:
2. Checking balance
To query the balance of an account, use thegetAddressBalance
method.
Example request:
3. Code Implementation
The script polls every 5 seconds and prints balance updates and new transactions.- JavaScript (@ton/core)
Install dependencies:Code:Output example:
4. Use Cases
- Notification bots – Send Telegram/Discord alerts when a user’s wallet receives or spends TON.
- Custodial wallets – Exchanges or custodians can track balances in real time for hot wallets.
- Developer debugging – Easily follow transaction activity while testing dApps or smart contracts.