Approve Transactions#
According to the ERC-20 standard , we need to make sure that the OKX router has permission to spend funds with the user's wallet before making a transaction. This API will generate the relevant data for calling the contract.
Request URL#
GET https://web3.okx.com/api/v6/dex/aggregator/approve-transaction
Request Parameters#
| Parameter | Type | Required | Description | 
|---|---|---|---|
| chainIndex | String | Yes | Unique identifier for the chain. e.g., 1: Ethereum.See more here. | 
| tokenContractAddress | String | Yes | Token contract address (e.g., 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) | 
| approveAmount | String | Yes | The amount of token that needs to be permitted (set in minimal divisible units, e.g., 1.00USDT set as1000000,1.00DAI set as1000000000000000000) | 
Response Parameters#
| Parameter | Type | Description | 
|---|---|---|
| data | String | Call data | 
| dexContractAddress | String | The contract address of OKX DEX approver (e.g., 0x6f9ffea7370310cd0f890dfde5e0e061059dcfd9) | 
| gasLimit | String | Gas limit   (e.g., 50000).To get accurate data, please take a look at /gas-limit API | 
| gasPrice | String | Gas price in wei      (e.g., 110000000) | 
Request Example#
shell
curl --location --request GET 'https://web3.okx.com/api/v6/dex/aggregator/approve-transaction?chainIndex=1&tokenContractAddress=0x6f9ffea7370310cd0f890dfde5e0e061059dcfd9&approveAmount=1000000' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'
Response Example#
200
{
 "code": "0",
 "data": [
   {
     "data": "0x095ea7b3000000000000000000000000c67879f4065d3b9fe1c09ee990b891aa8e3a4c2f00000000000000000000000000000000000000000000000000000000000f4240",
     "dexContractAddress": "0xc67879F4065d3B9fe1C09EE990B891Aa8E3a4c2f",
     "gasLimit": "50000",
     "gasPrice": "110000000"
   }
 ],
 "msg": ""
}
