Integration: Instant Payments
Prerequisites
- Register via Transfer Edge Dashboard and get your RPC URL and API Key. Basically, you don't need to top-up your account.
- Use the Transatron node for all TRON operations.
Not just/broadcasttransaction, but also resource estimation and monitoring. - 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. It's specifically designed for Instant payments.
- Configure energy price for your users. Transatron sell resources to you, and you sell resources to your customer. You can't change Transatron price, but you are free to set any price for your users. The difference is credited to your account as a Cashback. Energy price for users needs to be configured for each Non-Spender API Key individually. You can have as much API Keys, as you need (for A/B testing, or different products).
- Configure auto-refund. In Dashboard, add your refund address to Address Book, then configure Auto-Refund in Settings. This way your Cashback will be automatically delivered to your wallet.
Flow: Sending Transactions with Instant Payments
-
Estimate resources
Call/triggersmartcontractto estimate resources required for the user’s transaction. -
Parse Transatron response
In the JSON response, Transatron adds atransatronobject with fee data:tx_fee_rtrx_instant→ TRX fee requiredtx_fee_rusdt_instant→ USDT fee required
-
Create payment transaction
- Prepare a TRX or USDT payment transaction to the Transatron payment address.
- The amount must equal the required fee (
tx_fee_rtrx_instantortx_fee_rusdt_instant). - Sign it with the wallet’s private key.
-
Prepare the user transaction
- Construct and sign the transaction the user actually wants to broadcast.
-
Broadcast transactions sequentially
- First send the payment transaction.
- Wait until Transatron acknowledges it.
- Then send the user transaction.
-
Monitor
- Receive the transaction hash.
- Track confirmations as usual.
tip
Instant payments work with both TRX and USDT, but TRX is cheaper and recommended by default.
Handling Errors
-
Underpriced payment
- If the payment transaction does not cover the required fee, Transatron returns
INSTANT_PAYMENT_UNDERPRICED. - The user transaction is not broadcasted.
- Fix: re-estimate with
/triggersmartcontract, re-create the payment transaction, and try again.
- If the payment transaction does not cover the required fee, Transatron returns
-
Payment transaction failure
- If the payment transaction itself fails, Transatron does not broadcast the user transaction.
- Error returned:
NOT_ENOUGH_FUNDS(with message).
What if the User Doesn’t Want to Use Instant Payment?
You can simply prepare, sign, and broadcast the transaction via Transatron without an instant payment.
- Transatron will bypass fee coverage.
- The transaction is forwarded to TRON as-is.
- Fees will be charged directly by TRON (either by burning TRX or using staked resources).
Additional Information
- Example flows: Transatron TronWeb Examples (GitHub)
- Guide: Preparing and Broadcasting Transactions
- API reference: Extended RPC Calls