Accept USDT (TRC-20) payments on TRON with the RpcNode API
Create a payment with POST /v1/payments (network tron, the USDT contract as token_contract, a receiving address you control), show the address and amount to the customer, and fulfil the order when a signed payment_order webhook arrives with event: "paid". The same event carries the AML result. Payments need a paid plan: the Free plan has no payment slots.
What you need first
- A paid plan with Payments included. A new account can start a 7-day Starter trial from the cabinet; plans are listed on the pricing page. Prices and limits change, so read the page rather than this article.
- An API key from the cabinet: a UUID for
X-Api-Keyand a secret (sk_live_...) shown once. Every request is signed with HMAC-SHA256, see Authentication. The official SDKs (TypeScript, Python, PHP, Go, Kotlin) do the signing for you. - A TRON address you control. The API takes the address you give it and does not generate wallets or move funds. Check the address on your side before you store it.
- A public HTTPS URL for the webhook. Save it once with
PUT /v1/webhooks({"url": "...", "enabled": true}), then readwebhook.secretfromGET /v1/webhooks.
Step 1: take the token contract from the API
A token is chosen only by its contract address. token_symbol is rejected with a 400, so a payment is never silently made in TRX when you meant USDT. List the tokens that are enabled for payments on the network:
import crypto from 'node:crypto'
const BASE = 'https://api.rpcnode.dev'
const KEY = process.env.RPCNODE_API_KEY // UUID from the cabinet
const SECRET = process.env.RPCNODE_API_SECRET // sk_live_..., shown once
// Sign the exact string you send; the query string is part of the signed path.
async function api(method, path, payload) {
const body = payload === undefined ? '' : JSON.stringify(payload)
const ts = Math.floor(Date.now() / 1000)
const bodyHash = crypto.createHash('sha256').update(body, 'utf8').digest('hex')
const canonical = [ts, method, path, bodyHash].join('\n')
const signature = crypto.createHmac('sha256', SECRET).update(canonical, 'utf8').digest('hex')
const res = await fetch(BASE + path, {
method,
headers: {
'Content-Type': 'application/json',
'X-Api-Key': KEY,
'X-Timestamp': String(ts),
'X-Signature': signature,
},
body: body || undefined,
})
return res.json()
}
const { items } = await api('GET', '/v1/network-tokens?network_slug=tron')
console.log(items) // [{ network_slug, contract, symbol: 'USDT', decimals }, ...]
You can also confirm with GET /v1/networks that tron has mainnet in scan_environment_kinds, which is the list of environments where payments are available.
Step 2: create the payment
const created = await api('POST', '/v1/payments', {
order_id: 'ord_123', // your own order number, unique per account
network_slug: 'tron',
address: 'T...your receiving address',
amount: '30', // a string in whole units, never a number
token_contract: items.find((t) => t.symbol === 'USDT').contract,
ttl_seconds: 1800, // default is 3600
})
if (!created.ok) throw new Error(created.error_code)
console.log(created.payment.payment_id, created.payment.status, created.payment.expires_at)
The payment starts as pending. The call is idempotent per order_id: repeating it with the same parameters returns the existing payment with HTTP 200, and different parameters give 409 payment.order_exists. An expired payment is not recreated, so use a new order_id for a new attempt. The response also tells you required_confirmations, the number of blocks RpcNode waits for before it moves on (the docs example for TRON shows 19; read the value from your own response).
Step 3: receive the webhook
RpcNode sends a payment_order event on every status change to any enabled webhook with a URL. Verify the signature first, see how to verify a crypto webhook signature, then deduplicate by delivery_id:
import express from 'express'
import { verify } from './verify.js' // the function from the signature article
const WEBHOOK_SECRET = process.env.RPCNODE_WEBHOOK_SECRET
const AML_HOLD_SCORE = Number(process.env.AML_HOLD_SCORE) // your own policy
const app = express()
app.post('/rpcnode/webhook', express.raw({ type: '*/*' }), async (req, res) => {
if (!verify(req.body, req.get('X-RpcNode-Signature'), WEBHOOK_SECRET)) return res.sendStatus(401)
const event = JSON.parse(req.body.toString('utf8'))
if (event.type !== 'payment_order') return res.sendStatus(200)
if (await alreadyHandled(event.delivery_id)) return res.sendStatus(200)
const order = await findOrder(event.order_id) // match by YOUR order_id
if (order && order.paymentId === event.payment_id) {
if (event.event === 'paid') {
const enough = BigInt(event.received_amount_raw) >= BigInt(order.amountRaw)
const risky = event.aml && event.aml.score >= AML_HOLD_SCORE
await (enough && !risky ? fulfil(order, event) : holdForReview(order, event))
} else if (['expired', 'cancelled', 'failed'].includes(event.event)) {
await closeOrder(order, event.event, event.fail_reason)
}
// check, confirmations, aml_check and underpaid are progress: update the UI only
}
await rememberHandled(event.delivery_id)
res.sendStatus(200)
})
app.listen(3000)
alreadyHandled, findOrder, fulfil and the rest are yours. For the AML fields and how to pick a threshold, see AML checks for incoming crypto payments.
The lifecycle in one line
pending (waiting) leads to check (money seen, counting confirmations, one free confirmations event per block), then aml_check (screening, only on networks with an AML provider; TRON has one), then paid. Side exits are underpaid, expired, failed and cancelled. Fulfil only on paid. How long the confirmation wait lasts depends on the network, see confirmations by network.
Limits and caveats
- Matching rules. A transfer closes the payment if it is in a block after
min_block_height, is the same token, and is at least the requested amount. Overpayment is accepted andreceived_amount_rawshows what arrived. A smaller transfer leaves the paymentunderpaidand open until it expires. Use one address per order, or different amounts, if several payments can be open on one address. - Plan limits. The plan caps open payments, payments per month and watched addresses; the API answers 403 with
payment.slot_limit,payment.monthly_limitorwatch.address_limit. The Public API itself is limited to 100 requests per minute per account. - Credits. The first event of a payment (
check) is billed once at the network's payment price, whichGET /v1/networks/tron/creditsreturns. Progress events,paidand the AML result are not billed separately. - No promised latency. The time from transfer to
paiddepends on block production, confirmations and the AML provider. RpcNode does not publish an SLA. - Events are not a ledger. Delivery can repeat and arrive out of order. After downtime, reconcile with
GET /v1/payments/orders/{orderId}.
Next steps: the Payments product page, pricing, the Enterprise page if you need terms beyond the standard plans, the full Payments reference and the OpenAPI file.