Generate approve calldata to allow 1inch Router to perform a swap
Supported on: Ethereum Base BNB Chain Polygon Linea Sonic Unichain Arbitrum Avalanche ZKsync Gnosis Optimism
Parameters
chain
* number path tokenAddress
* string queryToken address you want to swap
amount
string queryThe number of tokens that the 1inch Router is allowed to swap.If not specified, it will be allowed to spend an infinite amount of tokens.
Request Body
This request doesn’t have any request body.
JavaScript
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const axios = require('axios');
async function httpCall() {
const url = 'https://api.1inch.com/swap/v6.1/{chain}/approve/transaction';
const config = {
headers: {
Authorization: `Bearer ${API_KEY}`,
},
params: {
tokenAddress: '0x111111111117dc0aa78b770fa6a738034120c302',
amount: '100000000000',
},
paramsSerializer: {
indexes: null,
},
};
const body = {};
try {
const response = await axios.get(url, body, config);
console.log(response.data);
} catch (error) {
console.error(error);
}
}
Returns
200
data
* string The encoded data to call the approve method on the swapped token contract
gasPrice
* string Network high gas price in wei
to
* string Token address that will be allowed to exchange through 1inch Router
value
* string Native token value in wei (for approve is always 0)
JSON
Copy
1
2
3
4
5
6
7
{
"data": "0x095ea7b30000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"gasPrice": "1000000000",
"to": "0x111111111117dc0aa78b770fa6a738034120c302",
"value": "0"
}