Trading Authorization Guide for DEX API

ยท

Overview

Under the ERC-20 Token Standard, users must authorize the OKX DEX router to access their wallet assets before executing swap transactions. This API provides the necessary transaction details to initiate an approval request.


API Endpoint

GET https://web3.okx.com/api/v5/dex/aggregator/approve-transaction


Request Parameters

ParameterTypeRequiredDescription
chainIdStringYesChain ID (e.g., 1 for Ethereum; see full list).
tokenContractAddressStringYesToken contract address (e.g., 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48).
approveAmountStringYesToken amount to approve (include decimals; e.g., 1000000 for 1.00 USDT).

Response Parameters

ParameterTypeDescription
dataStringCall data for the transaction.
dexContractAddressStringOKX DEX router contract address.
gasLimitStringGas limit (e.g., 50000).
gasPriceStringGas price in wei (e.g., 110000000).

Example Usage

Request Example

curl -X GET "https://web3.okx.com/api/v5/dex/aggregator/approve-transaction?chainId=1&tokenContractAddress=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&approveAmount=1000000"

Response Example

{
  "data": "0x...",
  "dexContractAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  "gasLimit": "50000",
  "gasPrice": "110000000"
}

FAQs

Why is token approval necessary?

Token approval ensures the DEX router can access the specified tokens in your wallet for swaps, adhering to ERC-20 security standards.

How do I calculate the correct approveAmount?

Multiply the token amount by its decimal precision (e.g., USDT uses 6 decimals: 1.00 * 10^6 = 1000000).

๐Ÿ‘‰ Learn more about DEX APIs

Can I revoke an approval?

Yes, send a new transaction with approveAmount set to 0.


Key Takeaways

๐Ÿ‘‰ Explore advanced Web3 integrations


### SEO Notes: