1inch API
Search…
Approve
Get calldata for approve transaction and spender address
All requests and examples are made for Ethereum mainnet, if you plan to use the API on other chains, change the request url as follows: https://api.1inch.exchange/v3.0/56/<method> — for Binance Smart Chain https://api.1inch.exchange/v3.0/137/<method> — for Polygon
get
https://api.1inch.exchange/v3.0/1
/approve/calldata
Approve Calldata
Do not combine amount parameter with infinity parameter, only one must be sent.
amount is set in minimal divisible units: for example, to unlock 1 DAI, amount should be 1000000000000000000, to unlock 1.03 USDC, amount should be 1030000.
Request url to unlock 5000 DAI tokens https://api.1inch.exchange/v3.0/1/approve/calldata?amount=5000000000000000000000&tokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f
curl curl -X GET "https://api.1inch.exchange/v3.0/1/approve/calldata?amount=5000000000000000000000&tokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f" -H "accept: application/json"
Response body
Response headers
1
{
2
"data": "0x095ea7b300000000000000000000000011111112542d85b3ef69ae05771c2dccff4faa26ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
3
"gasPrice": "51000000000",
4
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
5
"value": "0"
6
}
Copied!
1
access-control-allow-origin: *
2
cache-control: public,max-age=300,s-maxage=300
3
cf-cache-status: EXPIRED
4
cf-ray: 5f4206653b48e69c-LHR
5
cf-request-id: 067d2253420000e69c3e176000000001
6
content-encoding: gzip
7
content-type: application/json; charset=utf-8
8
date: Wed,18 Nov 2020 13:26:45 GMT
9
etag: W/"ec-iBWHynvCWl7Z7aoQEOVh6S9MqaM"
10
expect-ct: max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
11
server: cloudflare
12
status: 200
13
vary: Origin,Accept-Encoding
14
x-powered-by: Express
Copied!
Please, note some token contracts, like USDT, require to set approval back to zero, before increasing it.
It is recommended to make an estimate of this transaction before sending it to the node.
get
https://api.1inch.exchange/v3.0/1
/approve/spender
Approve Spender
Request url https://api.1inch.exchange/v3.0/1/approve/spender
curl curl -X GET "https://api.1inch.exchange/v3.0/1/approve/spender" -H "accept: application/json"
Response body
Headers
1
{
2
"address": "0x11111112542d85b3ef69ae05771c2dccff4faa26"
3
}
Copied!
1
access-control-allow-origin: *
2
cache-control: public,max-age=300,s-maxage=300
3
cf-cache-status: REVALIDATED
4
cf-ray: 5f4d1eb46d9807aa-LHR
5
cf-request-id: 06841184c0000007aa76229000000001
6
content-encoding: gzip
7
content-type: application/json; charset=utf-8
8
date: Thu,19 Nov 2020 21:45:44 GMT
9
etag: W/"38-OVahTHEixCdKnQb1Zt3v5Gr5QvY"
10
expect-ct: max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
11
server: cloudflare
12
status: 304
13
vary: Origin,Accept-Encoding
14
x-powered-by: Express
Copied!
Last modified 5mo ago