Approve

Get calldata for approve transaction and spender address

get
Approve Calldata

https://api.1inch.exchange/v2.0/approve/calldata
Get a calldata for an approve transaction.
Request
Response
Request
Query Parameters
amount
optional
integer
Amount of tokens to be approved: 0 — set approval to zero (lock a token) >0 — approve exact amount of tokens.
infinity
optional
boolean
If set, approve infinite amount of tokens
tokenAddress
required
string
The contract address of a token
Response
200: OK
Success response
{
"to": [
"string" // token contract address
],
"value": "string", // amount of eth to be sent (in wei)
"gasPrice": "string", // recommended gas price (in wei)
"data": "string" // result 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/v2.0/approve/calldata?amount=5000000000000000000000&tokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f

curl curl -X GET "https://api.1inch.exchange/v2.0/approve/calldata?amount=5000000000000000000000&tokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f" -H "accept: application/json"

Response body
Response headers
Response body
{
"data": "0x095ea7b3000000000000000000000000111111125434b319222cdbf8c261674adb56f3aeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"gasPrice": "51000000000",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"value": "0"
}
Response headers
access-control-allow-origin: *
cache-control: public,max-age=300,s-maxage=300
cf-cache-status: EXPIRED
cf-ray: 5f4206653b48e69c-LHR
cf-request-id: 067d2253420000e69c3e176000000001
content-encoding: gzip
content-type: application/json; charset=utf-8
date: Wed,18 Nov 2020 13:26:45 GMT
etag: W/"ec-iBWHynvCWl7Z7aoQEOVh6S9MqaM"
expect-ct: max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
status: 200
vary: Origin,Accept-Encoding
x-powered-by: Express

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.

Test your request in web interface: https://api.1inch.exchange/v2.0/swagger/#/Approve/getCallData

get
Approve Spender

https://api.1inch.exchange/v2.0/spender
Get the address to which you need to approve before the swap transaction
Request
Response
Request
Response
200: OK
Success response
{
"address": "string" // address of 1inch contract
}

Request url https://api.1inch.exchange/v2.0/approve/spender

curl curl -X GET "https://api.1inch.exchange/v2.0/approve/spender" -H "accept: application/json"

Response body
Headers
Response body
{
"address": "0x111111125434b319222cdbf8c261674adb56f3ae"
}
Headers
access-control-allow-origin: *
cache-control: public,max-age=300,s-maxage=300
cf-cache-status: REVALIDATED
cf-ray: 5f4d1eb46d9807aa-LHR
cf-request-id: 06841184c0000007aa76229000000001
content-encoding: gzip
content-type: application/json; charset=utf-8
date: Thu,19 Nov 2020 21:45:44 GMT
etag: W/"38-OVahTHEixCdKnQb1Zt3v5Gr5QvY"
expect-ct: max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
status: 304
vary: Origin,Accept-Encoding
x-powered-by: Express

Test your request in web interface: https://api.1inch.exchange/v2.0/swagger/#/Approve/getSpenderAddress