Integration: Coupon Payments
Prerequisites
- Register via Transfer Edge Dashboard and get your RPC URL and Spender API Key. Don't forget to top-up your account.
- Use the Transatron node for all TRON operations (not just
/broadcasttransaction). - Secure the Spender key. Never expose it in client apps or front-end code.
- Use the Non-Spender key. This type of API Key is safe to use on mobile devices and web front-ends. It doesn't let anyone to spend your internal balance.
Flow: Sending Transactions with Coupon Payments
- Wallet: Call
/triggersmartcontractto estimate resources. - Wallet: Read
tx_fee_rtrx_account/tx_fee_rusdt_accountfrom thetransatronJSON object in the response. - Wallet → Server: Send the fee estimate (and user identifiers) to your backend.
- Server: Use the Spender API key to create a coupon with a TRX/USDT limit.
- Optionally, set a slightly higher limit to avoid underfunding.
- Unused funds are automatically refunded to the company account.
- Transatron: Deducts the coupon limit from the company account and issues the coupon.
- Server → Wallet: Return the coupon code to the wallet.
- Wallet: Add the coupon id to the root JSON object of the signed user transaction and broadcast it to
/broadcasttransaction:{
....
"coupon":"<COUPON_ID>"
....
} - Transatron:
- Covers the transaction with resources.
- Refunds any unspent coupon balance to the company account.
- Example: Coupon = 15 TRX, transaction costs 10 TRX → 5 TRX refunded.
- Wallet: Receive the user transaction hash and monitor confirmations.
- Server: Book the fee. The fee figures in the broadcast reply are an estimate unless
is_finalistrue. Read the final charge with the Spender API key fromGET /api/v1/orders, by the reply'sorder_idor by the transaction hash (see How it works).
Handling Errors
- Spent, expired or too-low coupon: the coupon is ignored and the transaction is handled as one without a coupon, so the fee is charged to your account's internal balance, or the reply is
LIMIT_EXCEED/NOT_ENOUGH_FUNDSwhen the balance cannot cover it. A coupon pays for exactly one transaction.
warning
Always validate that coupon has enough TFN (former RTRX) to cover transaction and have not expired before broadcasting a transaction.
What if the User Wants to Burn TRX?
Simply prepare, sign, and broadcast the transaction as usual via Transatron.
- No coupon is applied.
- The transaction is forwarded to TRON unchanged.
- Fees are paid by burning TRX (or using staked resources).
Additional Information
- Example flows: Transatron TronWeb Examples (GitHub)
- Detailed description of Coupon API: Coupon API
- Guide: Preparing and Broadcasting Transactions
- API reference: Extended RPC Calls