Construct transaction
Build the unsigned TRON transactions your user signs, with no node or ABI encoding on your side.
Optional. You can build transactions yourself with TronWeb; Tronergy only needs a correctly signed transaction at Execute.
Build transactions
Returns unsigned transactions for a smart contract call, plus an inline quote. Limit: 30 per minute.
curl -X POST "https://apiv2.tronergy.io/api/chain_relayers/portal/construct-tx" \
-H "x-api-key: $TRONERGY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chain": "tron",
"mode": "sponsored_broadcast",
"environment": "live",
"senderAddress": "TUserAddressxxxxxxxxxxxxxxxxxxxxx",
"contractAddress": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"functionSelector": "transfer(address,uint256)",
"parameter": [
{
"type": "address",
"value": "TRecipientxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"type": "uint256",
"value": "25000000"
}
]
}'chainstringrequiredAlways tron.
mode"sponsored_broadcast" | "token_pay" | "trx_fee_token_pay"requiredsponsored_broadcast, token_pay or trx_fee_token_pay. For sunswap_swap, see below.
environment"sandbox" | "live"sandbox or live. Defaults to sandbox.
senderAddressstringrequiredYour user's TRON address. It signs every transaction.
contractAddressstringrequiredContract your user calls, for example USDT.
functionSelectorstringrequiredSolidity signature. Max 128 characters.
parameterArray<{ type: string; value: unknown }>Call arguments as { type, value }. Max 20.
feeLimitnumberMax sun each transaction may burn. Default and max 100000000.
callValuestring | numberTRX in sun attached to a payable user call. Max 1000000000000.
feeTokenContractstringtoken_pay only, required. Use feeTokenContract from Estimate.
feeAmountSunstring | numberFee amount, positive whole number. token_pay: token's smallest unit (feeAmount from Estimate). trx_fee_token_pay: sun (feeAmountSun).
feeRecipientstringWhere the fee goes. Use feeRecipient from Estimate.
feeFunctionSelectorstringtoken_pay only. Defaults to transfer(address,uint256).
feeParameterArray<{ type: string; value: unknown }>token_pay only. Overrides the fee call arguments. Max 20.
{
"ok": true,
"unsignedTxs": [
{ "id": "main", "label": "Transaction", "tx": { "txID": "...", "raw_data": {}, "raw_data_hex": "..." } }
],
"estimate": { "estimatedCostNative": "2.950000", "estimatedCostUsd": "0.84000000", "unit": "TRX" },
"expiresAt": "2026-10-21T10:15:00.000Z",
"expectedNetworkId": "tron:mainnet",
"decoded": {
"sender": "TUserAddress...",
"recipient": "TRecipient...",
"amount": "25000000",
"contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"function": "transfer(address,uint256)"
}
}| Mode | unsignedTxs | Send to Execute as |
|---|---|---|
sponsored_broadcast | main | payload.signed_tx |
token_pay, trx_fee_token_pay | fee_tx, then user_tx | payload.fee_signed_tx, payload.user_signed_tx |
estimateisnullif the quote failed; the transactions are still valid.expectedNetworkIdistron:mainnetfor live andtron:shastafor sandbox. Check the wallet is on it before signing.expiresAtis about 5 minutes out. Execute rejects a transaction with too little time left, so sign and submit promptly.
Sign the transactions exactly as returned. Changing any field after signing makes Execute reject them.
Swap step
For sunswap_swap, send only the session from Estimate. See Swap.
curl -X POST "https://apiv2.tronergy.io/api/chain_relayers/portal/construct-tx" \
-H "x-api-key: $TRONERGY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chain": "tron",
"mode": "sunswap_swap",
"environment": "live",
"payload": {
"session_id": "3f2a9c1e-7b4d-4e8a-9c2f-1a6b5d8e0f42"
}
}'chain"tron"requiredAlways tron.
mode"sunswap_swap"requiredAlways sunswap_swap.
environment"sandbox" | "live"sandbox or live. Defaults to sandbox.
payload{ session_id: string }required{ "session_id" } from the estimate response.
Common errors: 400 Invalid JSON body, 422 Validation failed, 422 Missing fee token contract, 422 Missing fee amount, 429, 500 Failed to construct transaction. See Errors.
Swap step errors:
409 SUNSWAP_SESSION_REPRICE_REQUIRED: the session's price is out of date for your account. Call Estimate again with the samesession_id, then construct-tx.409 SUNSWAP_OPERATION_IN_PROGRESS: a step is still running. Wait for it.409 SUNSWAP_SESSION_COMPLETED: the swap is done. Estimate again withoutsession_id.- Execute answers
409 DRAFT_STALEwhen the draft was superseded, priced for another account, or built before a platform update. Build the step again with construct-tx and re-sign.