Skip to main content

Integration: Coupon Payments

Prerequisites​

  1. Register via Transfer Edge Dashboard and get your RPC URL and Spender API Key. Don't forget to top-up your account.
  2. Use the Transatron node for all TRON operations (not just /broadcasttransaction).
  3. Secure the Spender key. Never expose it in client apps or front-end code.
  4. 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​

  1. Wallet: Call /triggersmartcontract to estimate resources.
  2. Wallet: Read tx_fee_rtrx_account / tx_fee_rusdt_account from the transatron JSON object in the response.
  3. Wallet → Server: Send the fee estimate (and user identifiers) to your backend.
  4. 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.
  5. Transatron: Deducts the coupon limit from the company account and issues the coupon.
  6. Server → Wallet: Return the coupon code to the wallet.
  7. Wallet: Add the coupon id to the root JSON object of the signed user transaction and broadcast it to /broadcasttransaction:
    {
    ....
    "coupon":"<COUPON_ID>"
    ....
    }
  8. 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.
  9. Wallet: Receive the user transaction hash and monitor confirmations.
  10. Server: Book the fee. The fee figures in the broadcast reply are an estimate unless is_final is true. Read the final charge with the Spender API key from GET /api/v1/orders, by the reply's order_id or 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_FUNDS when 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​

  1. Example flows: Transatron TronWeb Examples (GitHub)
  2. Detailed description of Coupon API: Coupon API
  3. Guide: Preparing and Broadcasting Transactions
  4. API reference: Extended RPC Calls