Guides

How to accept USDT (TRC-20) payments in your app

1 December 2026 · 4 min read

USDT on Tron is the most common way people move dollars in crypto: fees are low and almost every exchange supports it. If your app lets customers top up, pay invoices or fund a wallet, TRC-20 USDT is usually the first network they ask for.

This guide shows the whole flow: give each customer their own Tron address, get told the moment USDT arrives, and credit them once. Everything runs in test mode first, so you can build it without real money.

How USDT on Tron actually arrives

A USDT deposit is not a TRX transfer. It's a call to the USDT contract (TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t) that moves tokens to your address. That's why checking an address's TRX balance never shows it, and why you have to read the contract's Transfer events to know a customer paid.

Doing that yourself means running or renting a Tron node, reading every block (one every 3 seconds), matching Transfer events against all your addresses, and tracking confirmations. The rest of this guide uses the BlocksReader API, which does that reading for you and sends a webhook instead.

1. Create a deposit address per customer

One request per customer. ref is your own id for them, and every deposit to the address comes back tagged with it.

bash
curl https://api.blocksreader.com/v1/addresses \
  -H "Authorization: Bearer $BLOCKSREADER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "chain": "tron", "ref": "customer_8431" }'

The response has an id (starting adr_) and the address to show your customer. Save both against the customer. The address is theirs from now on, so they can save it and top up any time.

The address comes from your own wallet. In live mode your wallet is created by the BlocksReader Signer on your server, and the keys stay with you, so nobody but you can move the funds.

2. Register a webhook endpoint

bash
curl https://api.blocksreader.com/v1/webhooks \
  -H "Authorization: Bearer $BLOCKSREADER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://your-app.com/webhooks/blocksreader", "events": ["deposit.confirmed"] }'

Save the secret (whsec_...) from the response as BLOCKSREADER_WEBHOOK_SECRET. It's shown once.

3. Handle deposit.confirmed and credit once

When USDT arrives you receive deposit.confirmed, once at 1 confirmation and again at 3. The data includes chain, address, tx_hash, amount (already in USDT, as a string), asset (the token contract), ref and, when a price is known, amount_usd.

The rule that keeps balances right: credit on the pair (chain, tx_hash, address), never on the event id, and do it in one database transaction with a unique constraint.

js
import crypto from 'node:crypto';
import express from 'express';

const app = express();
const SECRET = process.env.BLOCKSREADER_WEBHOOK_SECRET;
const USDT_TRON = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';

app.post('/webhooks/blocksreader', express.raw({ type: 'application/json' }), async (req, res) => {
  const parts = Object.fromEntries(String(req.get('BR-Webhook-Signature') || '').split(',').map((p) => p.split('=')));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > 300) return res.sendStatus(401);
  const expected = crypto.createHmac('sha256', SECRET).update(`${t}.${req.body}`).digest('hex');
  const got = String(parts.v1 || '');
  if (got.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected))) return res.sendStatus(401);

  const event = JSON.parse(req.body);

  if (event.type === 'deposit.confirmed' && event.data.asset === USDT_TRON) {
    const d = event.data;
    // In one transaction:
    //   INSERT INTO deposits (chain, tx_hash, address, customer_ref, amount)
    //   VALUES ($1, $2, $3, $4, $5) ON CONFLICT (chain, tx_hash, address) DO NOTHING
    //   -- only if a row was inserted:
    //   INSERT INTO balances (customer_ref, usdt) VALUES ($4, $5)
    //   ON CONFLICT (customer_ref) DO UPDATE SET usdt = balances.usdt + EXCLUDED.usdt
    try {
      await creditOnce(d.chain, d.tx_hash, d.address, d.ref, d.amount);
    } catch (e) {
      console.error(e);
      return res.sendStatus(500); // not saved: the webhook is retried
    }
  }
  res.sendStatus(200); // reply within 10 seconds; do slow work (emails, other APIs) in a background job
});

Keep amounts as strings or decimals all the way to your database. Never turn "25.123456" into a floating-point number.

4. Test it without real USDT

With a test key (br_test_...) you can simulate a payment into the address from step 1:

bash
curl https://api.blocksreader.com/v1/sandbox/deposits \
  -H "Authorization: Bearer $BLOCKSREADER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "address_id": "adr_...", "amount": "25", "asset": "USDT" }'

About 5 seconds later your endpoint gets deposit.confirmed, and again about 6 seconds after that. Check that the customer's balance went up by 25 exactly once.

5. Add a catch-up job

Webhooks can be missed while you deploy or if your server is down. Every few minutes, page through GET /v1/deposits?chain=tron&status=confirmed (newest first) back over a fixed window, such as the last 48 hours, and pass every deposit through the same creditOnce function. Don't stop at the first one you've already credited: an older one may still be missing. Because of the unique key, running it twice is harmless.

Before you go live

  • Run the BlocksReader Signer on a server you control. It creates your wallet and later signs withdrawals and sweeps.
  • Set up sweeps: USDT spread across many customer addresses gets collected into one wallet automatically. Moving USDT needs a little TRX for energy, so set a gas tank address in Signer settings.
  • Switch to your br_live_ key and register your production webhook with it.

Pricing is pay as you go: 0.5% of incoming live deposits, nothing on payouts or sweeps, and test mode is free.