Docs / Guides / Polling vs webhooks

Polling vs webhooks for TRON deposits

The polling loop is a weekend project. The polling loop that never loses money is not.

The weekend version

while (true) {
  const block = await tronWeb.trx.getBlockByNumber(++height);
  for (const tx of block.transactions ?? []) {
    if (isUsdtTransferToUs(tx)) creditDeposit(tx);
  }
  await sleep(3000);
}

It works in the demo. Then it meets production.

The real checklist

Each item is a few days and an incident. Every team building on TRON writes this same scraper, badly, once.

When polling is right anyway

Honest answer: sometimes. If you already run TRON nodes, need sub-block custom analytics, or have compliance reasons to keep everything in-house — build the pipeline; the checklist above is your spec. For everyone else, deposit detection is undifferentiated plumbing.

The webhook trade

A watch API inverts the model: you register addresses once, and a service that already solved finality, cursors, catch-up, rate limiting and retries POSTs you a signed event when a deposit is confirmed — with an events API to reconcile whenever you're paranoid (be paranoid: it's money).

const th = new TronHooks('tw_live_...');
await th.watches.create({ address: 'T...', assetFilter: 'USDT', webhookUrl: 'https://you.dev/hook' });
// done — verify signatures on arrival, dedupe on event_id

tronhooks runs the loop so you don't: confirmed-only events, signed deliveries, full audit trail. Free for 3 addresses — or skip code entirely with Telegram alerts.

5-minute quickstart →