Tronergydocs

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.

POST/api/chain_relayers/portal/construct-tx
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"
      }
    ]
  }'
Parameters
chainstringrequired

Always tron.

mode"sponsored_broadcast" | "token_pay" | "trx_fee_token_pay"required

sponsored_broadcast, token_pay or trx_fee_token_pay. For sunswap_swap, see below.

environment"sandbox" | "live"

sandbox or live. Defaults to sandbox.

senderAddressstringrequired

Your user's TRON address. It signs every transaction.

contractAddressstringrequired

Contract your user calls, for example USDT.

functionSelectorstringrequired

Solidity signature. Max 128 characters.

parameterArray<{ type: string; value: unknown }>

Call arguments as { type, value }. Max 20.

feeLimitnumber

Max sun each transaction may burn. Default and max 100000000.

callValuestring | number

TRX in sun attached to a payable user call. Max 1000000000000.

feeTokenContractstring

token_pay only, required. Use feeTokenContract from Estimate.

feeAmountSunstring | number

Fee amount, positive whole number. token_pay: token's smallest unit (feeAmount from Estimate). trx_fee_token_pay: sun (feeAmountSun).

feeRecipientstring

Where the fee goes. Use feeRecipient from Estimate.

feeFunctionSelectorstring

token_pay only. Defaults to transfer(address,uint256).

feeParameterArray<{ type: string; value: unknown }>

token_pay only. Overrides the fee call arguments. Max 20.

Response
{
  "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)"
  }
}
ModeunsignedTxsSend to Execute as
sponsored_broadcastmainpayload.signed_tx
token_pay, trx_fee_token_payfee_tx, then user_txpayload.fee_signed_tx, payload.user_signed_tx
  • estimate is null if the quote failed; the transactions are still valid.
  • expectedNetworkId is tron:mainnet for live and tron:shasta for sandbox. Check the wallet is on it before signing.
  • expiresAt is 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.

POST/api/chain_relayers/portal/construct-tx
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"
    }
  }'
Parameters
chain"tron"required

Always tron.

mode"sunswap_swap"required

Always 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 same session_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 without session_id.
  • Execute answers 409 DRAFT_STALE when the draft was superseded, priced for another account, or built before a platform update. Build the step again with construct-tx and re-sign.