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
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | String | Yes | Chain ID (e.g., 1 for Ethereum; see full list). |
tokenContractAddress | String | Yes | Token contract address (e.g., 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48). |
approveAmount | String | Yes | Token amount to approve (include decimals; e.g., 1000000 for 1.00 USDT). |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
data | String | Call data for the transaction. |
dexContractAddress | String | OKX DEX router contract address. |
gasLimit | String | Gas limit (e.g., 50000). |
gasPrice | String | Gas 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
- Always verify contract addresses before approving.
- Use the
gasLimitandgasPriceprovided to avoid transaction failures. - Monitor blockchain explorers for transaction status.
๐ Explore advanced Web3 integrations
### SEO Notes: