Skip to main content
POST
/
95e61622bf6a8af293978377718e3b77
/
wallet
/
exchangetransaction
Execute a token swap transaction
curl --request POST \
  --url https://tron-mainnet.core.chainstack.com/95e61622bf6a8af293978377718e3b77/wallet/exchangetransaction \
  --header 'Content-Type: application/json' \
  --data '{
  "owner_address": "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH",
  "exchange_id": 1,
  "token_id": "1000001",
  "quant": 100000000000,
  "expected": 95000000,
  "visible": true
}'
{
  "txID": "c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "owner_address": "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH",
            "exchange_id": 1,
            "token_id": "1000001",
            "quant": "100000000000",
            "expected": "95000000"
          },
          "type_url": "type.googleapis.com/protocol.ExchangeTransactionContract"
        },
        "type": "ExchangeTransactionContract"
      }
    ],
    "ref_block_bytes": "ab93",
    "ref_block_hash": "f5d4c3b2a4",
    "expiration": 1672531440000,
    "timestamp": 1672531380000
  },
  "raw_data_hex": "0a02ab931220f5d4c3b2a440a0fee2f6e30f5a68081112620a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e45786368616e67655472616e73616374696f6e436f6e747261637412280a154c7971797a56474c5631737266b7dd4afc8eagg61535422083931303030303030303030"
}
TRON API method that executes a token swap transaction on the TRON decentralized exchange.
Get you own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • owner_address — the address performing the token swap (base58 with visible: true, or hex with visible: false).
  • exchange_id — unique identifier of the exchange pair to trade on.
  • token_id — token ID being sold; use _ to denote TRX.
  • quant — integer amount being sold (token base units; if TRX, specify in sun).
  • expected — integer minimum to receive (token base units; if TRX, sun). Protects against slippage.
  • permission_id — optional permission ID for multi‑signature accounts.

Response

Returns a transaction object containing:
  • txID — unique transaction identifier
  • raw_data — raw transaction data including contract details
  • raw_data_hex — hexadecimal representation of raw transaction data

Use case

The wallet/exchangetransaction method is used for:
  • Swapping tokens directly on the TRON decentralized exchange
  • Converting between TRX and TRC20 tokens at current market rates
  • Building arbitrage bots and automated trading strategies
  • Implementing token exchange functionality in decentralized applications

curl example

Shell
curl --request POST \
  --url 'https://tron-mainnet.core.chainstack.com/95e61622bf6a8af293978377718e3b77/wallet/exchangetransaction' \
  --header 'Content-Type: application/json' \
  --data '{
  "owner_address": "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH",
  "exchange_id": 1,
  "token_id": "1000001",
  "quant": 100000000000,
  "expected": 95000000,
  "visible": true
}'
  • amounts must be integers (do not quote numbers). If TRX is involved (token_id is ”_” on either side of the pair), express TRX values in sun (1 TRX = 1,000,000 sun).
  • the call returns an unsigned transaction; sign and broadcast it. On mainnet, the exchange must exist and you must have sufficient balance; slippage protection may reject if market has moved.

Body

application/json
owner_address
string
required

The address performing the token swap transaction

exchange_id
integer
required

Unique identifier of the exchange pair to trade on

token_id
string
required

Token ID being sold. Use '_' to denote TRX.

quant
integer
required

Amount being sold as an integer (token base units; if TRX, specify in sun)

expected
integer
required

Minimum amount to receive as an integer (token base units; if TRX, sun). Protects against slippage.

permission_id
integer

Optional permission ID for multi-signature accounts

visible
boolean
default:false

Whether to return human-readable addresses

Response

Successful response with transaction details

txID
string

Unique transaction identifier

raw_data
object

Raw transaction data including contract details

raw_data_hex
string

Hexadecimal representation of raw transaction data