Deposit methods comparison
Invoice-based flow Unique deposit address flow Comparison table| Criteria | Invoice-based deposits | Unique deposit addresses |
|---|---|---|
| Security exposure | One shared hot wallet; a key leak drains the full pool | Each wallet isolates funds; compromise affects only the impacted user |
| User input requirements | User must include an invoice ID comment; missing or malformed comments need manual recovery workflows | User only needs the destination address |
| Parsing and validation | Backend parses comments on every deposit and matches to invoices | No parsing; deposit attribution is address-based |
| Deployment and storage costs | Deploy and maintain a single wallet; storage rent limited to that contract | Deploy many wallets; storage rent and deployment gas scale with user count |
| Monitoring workload | Poll one address; comment parsing adds CPU but RPC calls stay low | Track many addresses; RPC queries and state tracking grow with the active user base |
| Withdrawal handling | Highload wallet can batch withdrawals from one balance | Need sweeps or coordinated withdrawals from many wallets; extra gas and sequencing logic |
| Sharding behavior | All activity hits one shard; throughput limited by that shard | Wallets are distributed across shards; helps spread load |
Invoice-based deposits
Invoice-based processing uses one wallet address to receive payments from all users. Each payment includes a unique identifier in the transaction comment field, allowing the service to attribute deposits to specific users. The implementation deploys one wallet contract (typically Highload) and generates unique invoice identifiers for each deposit. Users send Toncoin to this shared address with their invoice identifier as the comment. The service polls the wallet’s transaction history, extracts comments from incoming messages, matches them against stored invoices, and credits user accounts accordingly. Transaction comments in TON use the text message format; read more in How TON wallets work.Funds at riskRisk: deposits without the correct invoice identifier may be lost.
Scope: incoming transfers to the shared deposit address.
Mitigation: enforce invoice format; reject or hold unmatched deposits; provide a recovery workflow; document comment entry in the UI.
Environment: validate the full flow on testnet before enabling mainnet.
- Single wallet simplifies key management
- Reduced gas costs for deployments
- Withdrawals can batch multiple user requests into one transaction using a Highload wallet
- The approach scales well for high transaction volumes
- Access leak to the single hot wallet could lead to all user funds loss
- Users must correctly input the invoice identifier, and mistakes result in lost or misdirected funds
- Comment parsing adds complexity
- Some user wallet applications don’t support comments, limiting accessibility
- Single wallet network load won’t be sharded
Unique deposit addresses
Unique address deposits generate a separate wallet contract for each user. The user deposits to their dedicated address, and the service monitors all deployed wallets for incoming transactions. No comment parsing is required since each address maps to exactly one user. Implementation requires a wallet generation strategy. The most common approach uses a deterministic scheme based on a master seed and user identifiers. For V4 and V5 wallets, use differentsubwallet_id combinations. Alternatively, generate unique keypair per user, though this increases key management complexity.
Funds at riskRisk: funds sent to a non‑existent or wrong address are irrecoverable.
Scope: deposit address derivation and the first transfer to an un-deployed wallet.
Mitigation: derive addresses deterministically; verify checksum/ownership; send a small test transfer on testnet; use non‑bounceable for the first deposit; deploy immediately after receipt.
Environment: validate the full flow on testnet before using mainnet.
Keys and funds at riskRisk: leaked or mishandled private keys enable wallet takeover and fund loss.
Scope: generation, storage, and access to per-user wallet keys and deployment workflow.
Mitigation: encrypt keys at rest; restrict access; rotate keys; monitor deployment status; verify destination addresses before crediting deposits.
Environment: validate key management and deployment flow on testnet before mainnet.
seqno, creating bottlenecks under high load.
Advantages:
- No comment parsing removes a major source of user error
- Better security since each user has a unique keypair
- Transaction monitoring is straightforward - any incoming transaction to a user’s address is their deposit
- Higher operational complexity managing multiple wallets
- Deployment costs multiply by the number of users
- Withdrawal processing requires coordination across wallets
- Storage fees apply to each deployed contract (currently ~0.001 TON per year per contract)
Withdrawal batching
Highload wallets support parallel message processing by storing processed request identifiers instead of sequentialseqno. This enables batching multiple withdrawals into one transaction, reducing fees and improving throughput.
Common abuse patterns
- Reusing a previously settled invoice identifier to trigger duplicate credits when the backend does not invalidate the invoice after first use.
- Changing the Toncoin amount but leaving the original invoice identifier to obtain services at a lower price if expected amounts are not enforced.
- Crafting comments that mimic another users invoice identifier in order to hijack their pending credit.
- Submitting large numbers of dust payments to inflate processing costs or exhaust rate limits on transaction polling.
Monitoring best practices
Implement exponential backoff for RPC failures. Network issues or node maintenance can interrupt transaction polling. WhengetTransactions fails, wait before retrying with increasing delays to avoid overwhelming the endpoint.
Store transaction state persistently. Record the last processed lt value and transaction hash to resume monitoring after restarts without reprocessing transactions. This prevents duplicate deposit credits.
Use multiple RPC endpoints for reliability. TON has several public API providers and liteserver networks. Implement fallback logic to switch endpoints if the primary becomes unavailable. Compare results across endpoints to detect potential inconsistencies.
Log all processing decisions including deposit credits, withdrawal submissions, and failed transactions. These logs are essential for debugging user reports and auditing system behavior. Include transaction hashes, logical times, amounts, and user identifiers in logs.