A Google Apps Script project for tracking USDT transactions and wallet balances across multiple blockchain networks, all within a Google Spreadsheet.
- Multi-network support -- track USDT on TRC20 (TRON), BEP20 (BSC), and TON networks from a single spreadsheet
- Precision string arithmetic -- raw blockchain values are divided using string-based math (not
parseFloat, notBigInt), which prevents JavaScript floating-point errors for large integers (critical for BEP20 with 18 decimals) - Adapter pattern -- each network implements a uniform adapter interface, making it straightforward to add new networks
- Automatic deduplication -- transactions are deduplicated by
hash + wallet_namebefore writing - Safe balance updates -- balance functions return
nullon API errors so that a valid balance is never overwritten with zero - Built-in TON address parsing -- no external TonWeb dependency required
- Dust filtering -- BEP20 transfers under 0.5 USDT and zero-amount transfers are ignored
- Cooldown logic -- enforces a minimum interval (default 5 min) between update cycles
| Network | Token | Decimals | API Provider |
|---|---|---|---|
| TRC20 | USDT (TRON) | 6 | TronGrid v1 |
| BEP20 | USDT (BSC) | 18 | NodeReal MegaNode API (free tier) |
| TON | USDT (TON) | 6 | Toncenter v3 |
The spreadsheet uses two sheets. Their names are configurable in config.gs.
| Column | Content |
|---|---|
| A | Wallet address |
| B | Name / description |
| C | Network (TRC20 / BEP20 / TON) |
| D | USDT balance (updated automatically) |
| G1 | Timestamp of the last balance update |
| Column | Content |
|---|---|
| A | Date |
| B | Income |
| C | Expense |
| D | Wallet |
| E | Network |
| F | Hash |
Note: Sheet names and column headers are configurable in
config.gs.
- Open a Google Spreadsheet.
- Go to Extensions > Apps Script.
- Create the script files listed below, preserving the exact load order (the order matters in GAS):
1. config.gs 2. utils.gs 3. trc20.gs 4. bep20.gs 5. ton.gs 6. network_tracker.gs 7. wallets.gs 8. main.gs - Copy the corresponding source code into each file.
- Fill in your API keys in
config.gs(see the Configuration section). - Create the two sheets ("Wallets" and "Transactions") or update the names in
config.gs. - Populate the Wallets sheet with your addresses, names, and networks.
- Run
trackAllTransactions()manually or set up a time-driven trigger.
| Function | Description |
|---|---|
trackAllTransactions() |
Full cycle: update balances, then track all networks |
runTRC20Tracking() |
Track TRC20 transactions only |
runBEP20Tracking() |
Track BEP20 transactions only |
runTONTracking() |
Track TON transactions only |
runBalanceUpdate() |
Update wallet balances only |
All settings live in config.gs.
| Key | Service |
|---|---|
TRONGRID_API_KEY |
TronGrid API (TRC20) |
TONCENTER_API_KEY |
Toncenter API (TON) |
NODEREAL_API_KEY |
NodeReal MegaNode API (BEP20) |
| Parameter | Default | Description |
|---|---|---|
TIME_THRESHOLD_DAYS |
90 | Transactions older than this are ignored |
TRON_GRID_LIMIT |
50 | Max TRC20 transactions per API request |
TON_CENTER_LIMIT |
100 | Max TON events per API request |
| Cooldown | 5 min | Minimum interval between balance update cycles |
Each network module (trc20.gs, bep20.gs, ton.gs) exports an adapter object with two methods:
fetchTransactions(address)-- retrieves raw transactions from the blockchain API.processTransaction(tx, address, name, cutoffDate)-- converts a raw transaction into a spreadsheet row:[Date, Incoming, Outgoing, Wallet, Network, Hash].
The universal handler in network_tracker.gs (trackNetworkTransactions) reads wallets from the Wallets sheet, filters by network, calls the adapter for each wallet, deduplicates by hash + wallet_name, and appends new rows to the Transactions sheet.
The toTokenAmount(rawValue, decimals) function in utils.gs performs string-based division of raw blockchain integers by 10^decimals. This avoids JavaScript's loss of precision for integers larger than 2^53, which is especially important for BEP20 USDT where raw values have 18 decimal places.
- TRC20: only
Transfertype events; filtered by the USDT contract address. - BEP20: hex-to-decimal conversion (NodeReal returns hex); dust filter (< 0.5 USDT) and zero-amount filter.
- TON: event types
jetton_transferandjetton_swap; filtered by USDT master address. - All networks: deduplication by
hash + wallet_name; cutoff by date (configurable, default 90 days).
- TRC20 API returns a maximum of 50 recent transactions per request (TronGrid limit).
- TON API returns a maximum of 100 recent events per request (Toncenter limit).
- Google Apps Script has a 6-minute execution time limit for consumer (non-Workspace) accounts.
MIT