Skip to main content
Version: 2.0

Cheat Sheet

πŸ“ƒ Chain Support​

Swap and Gasless v2 APIs are currently supported on the following chains. Select the chain in your request by providing the corresponding chainId request parameter. To request support for a new chain, please submit a request here.

ChainChain IDSwap APIGasless API
Ethereum (Mainnet)1βœ…βœ…
Arbitrum42161βœ…βœ…
Avalanche43114βœ…βœ…
Base8453βœ…βœ…
Blast81457βœ…βœ…
BSC56βœ…βœ…
Linea59144βœ…
Mantle5000βœ…βœ…
Mode34443βœ…βœ…
Monad10143βœ…
Optimism10βœ…βœ…
Polygon137βœ…βœ…
Scroll534352βœ…βœ…
World Chain480βœ…

Swap API v2​

Sample Request and Response​

See full list of required query parameters and responses here.

Request​

curl --request GET \
--url 'https://api.0x.org/swap/permit2/quote?chainId=1&sellAmount=100000000000000000000&taker=0xa423C7Be031E988B25fb7Ec39b7906582f6858c6&sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&buyToken=0x6b175474e89094c44da98b954eedeac495271d0f' \
--header '0x-api-key: YOUR_API_KEY'
--header '0x-api-key: v2'

Response​

Expand to see response
{
"blockNumber": "20170903",
"buyAmount": "340843848647293527128015",
"buyToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
"fees": {
"integratorFee": null,
"zeroExFee": {
"amount": "512033823706500040753",
"token": "0x6b175474e89094c44da98b954eedeac495271d0f",
"type": "volume"
},
"gasFee": null
},
"gas": "522732",
"gasPrice": "14551300000",
"issues": {
"allowance": {
"actual": "0",
"spender": "0x000000000022d473030f116ddee9f6b43ac78ba3"
},
"balance": {
"token": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"actual": "0",
"expected": "100000000000000000000"
},
"simulationIncomplete": false,
"invalidSourcesPassed": []
},
"liquidityAvailable": true,
"minBuyAmount": "337435410160820591856735",
"route": {
"fills": [
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V3",
"proportionBps": "10000"
},
{
"from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "Maker_PSM",
"proportionBps": "10000"
}
],
"tokens": [
{
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"symbol": "WETH"
},
{
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"symbol": "USDC"
},
{
"address": "0x6b175474e89094c44da98b954eedeac495271d0f",
"symbol": "DAI"
}
]
},
"sellAmount": "100000000000000000000",
"sellToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"totalNetworkFee": "7606430151600000"
}

Gasless API v2​

Sample Request and Response​

See full list of required query parameters and responses here.

Request​

curl --request GET \
--url 'https://api.0x.org/gasless/quote?chainId=8453&sellToken=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913&buyToken=0x4200000000000000000000000000000000000006&sellAmount=100000000&taker=0x4D2A422dB44144996E855ce15FB581a477dbB947' \
--header '0x-api-key: YOUR_API_KEY'
--header '0x-version: v2'

Response​

Expand to see response
{
"approval": {
"type": "permit",
"hash": "0x334281749a8d1c7e518024109ee8f31c5e55109764efa33b2864a6ab26d90889",
"eip712": {
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Permit": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
}
]
},
"domain": {
"name": "USD Coin",
"version": "2",
"chainId": 8453,
"verifyingContract": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
},
"message": {
"owner": "0x4d2a422db44144996e855ce15fb581a477dbb947",
"spender": "0x000000000022d473030f116ddee9f6b43ac78ba3",
"value": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
"nonce": 1,
"deadline": "1720033166"
},
"primaryType": "Permit"
}
},
"blockNumber": "16621609",
"buyAmount": "28520257810978",
"buyToken": "0x4200000000000000000000000000000000000006",
"fees": {
"integratorFee": null,
"zeroExFee": {
"amount": "150",
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"type": "volume"
},
"gasFee": {
"amount": "5842",
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"type": "gas"
}
},
"issues": {
"allowance": null,
"balance": null,
"simulationIncomplete": false,
"invalidSourcesPassed": []
},
"liquidityAvailable": true,
"minBuyAmount": "28434697037546",
"route": {
"fills": [
{
"from": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"to": "0x4200000000000000000000000000000000000006",
"source": "Solidly_V3",
"proportionBps": "10000"
}
],
"tokens": [
{
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"symbol": "USDC"
},
{
"address": "0x4200000000000000000000000000000000000006",
"symbol": "WETH"
}
]
},
"sellAmount": "99850",
"sellToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"target": "0x5ce929ddb01804bff35b2f5c77b735bdb094aac8",
"trade": {
"type": "settler_metatransaction",
"hash": "0xf8b1cea260453fabbeb8d38195e3f034b638714553084753bbe83f4d2aaa45ba",
"eip712": {
"types": {
"PermitWitnessTransferFrom": [
{
"name": "permitted",
"type": "TokenPermissions"
},
{
"name": "spender",
"type": "address"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
},
{
"name": "slippageAndActions",
"type": "SlippageAndActions"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"TokenPermissions": [
{
"name": "token",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"SlippageAndActions": [
{
"name": "recipient",
"type": "address"
},
{
"name": "buyToken",
"type": "address"
},
{
"name": "minAmountOut",
"type": "uint256"
},
{
"name": "actions",
"type": "bytes[]"
}
]
},
"domain": {
"name": "Permit2",
"chainId": 8453,
"verifyingContract": "0x000000000022d473030f116ddee9f6b43ac78ba3"
},
"message": {
"permitted": {
"token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"amount": "100000"
},
"spender": "0x5ce929ddb01804bff35b2f5c77b735bdb094aac8",
"nonce": "2241959297937691820908574931991566",
"deadline": "1720032866",
"slippageAndActions": {
"recipient": "0x4d2a422db44144996e855ce15fb581a477dbb947",
"buyToken": "0x4200000000000000000000000000000000000006",
"minAmountOut": "28434697037546",
"actions": [
"0x0dfeb4190000000000000000000000005ce929ddb01804bff35b2f5c77b735bdb094aac8000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000186a00000000000000000000000000000000000006e898131631616b1779bad70bc0e0000000000000000000000000000000000000000000000000000000066859e62",
"0x38c9c147000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000000257000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000009f6601854dee374b1bfaf6350ffd27a97309d431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0x38c9c147000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000002710000000000000000000000000551a0e3d267bea87048f08cc94cc6035ad99221b000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000084c31b8d7a0000000000000000000000005ce929ddb01804bff35b2f5c77b735bdb094aac80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001860a000000000000000000000000fffd8963efd1fc6a506488495d951d5263988d2500000000000000000000000000000000000000000000000000000000"
]
}
},
"primaryType": "PermitWitnessTransferFrom"
}
}
}

0x Contracts​

This section provides an overview of the three main contracts developers need to understand when working with the 0x API - 0x Settler, AllowanceHolder, and Permit2. For more in-depth details, refer to the 0x Contracts section.

A Note About Setting Token Allowances​

danger
  • NEVER set an allowance on the Settler contract. Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties.

  • ONLY set allowances on Permit2 or AllowanceHolder contracts, as indicated by the API responses.

  • The correct allowance target is returned in issues.allowance.spender. :::

0x Settler Contracts​

The 0x Settler contract is the core execution layer of 0x v2, designed for flexibility and security. It dynamically updates based on the latest deployments and handles swaps without requiring passive token allowances.

Key Points:

  • Avoid setting token allowances on the Settler contract; it does not require them.
  • The entry point contract (where you send data) changes dynamically per deployment.
  • The correct contract address is always returned in transaction.to via the API.

Further reading: 0x Settler

Permit2 Contract​

The Permit2 contract, developed by Uniswap, enables gas-efficient and flexible token approvals. It eliminates the need for repeated approvals and enhances security by supporting time-limited, granular approvals.

When using the Swap API with Permit2, the Permit2 contract is the allowance target (also referred to as the spender or operator):

Key Points:

  • The correct allowance target will be returned in issues.allowance.spender.
  • Recommened for most applications, including multisig and smart contract wallets, as long as the smart contract supports EIP-1271, which most do.
  • Permit2 is deployed to 0x000000000022D473030F116dDEE9F6B43aC78BA3 across all chains. You can hardcode this address in your integration.

Further Reading: Permit2 Contract

AllowanceHolder Contract​

We recommend using Permit2 for most situations. However, if your integration doesn't support a double-signature flow, such as with smart contracts that aren't compatible with EIP-1271, AllowanceHolder is a better choice. It works best for single-signature use cases, including:

Projects integrating the Swap API into smart contracts without EIP-1271 support. Teams aggregating across multiple sources and aiming for a consistent user experience across all integrations.

For AllowanceHolder, use the following endpoints:

Key Points:

  • The correct allowance target will be returned in issues.allowance.spender.
  • More flexible than the traditional contract-wide approvals.
  • The AllowanceHolder contract is deployed at different addresses, depending on the chain’s latest supported EVM hardfork. These addresses can be hardcoded in your integration:
    • 0x0000000000001fF3684f28c67538d4D072C22734 on chains supporting the Cancun hardfork (Ethereum Mainnet, Ethereum Sepolia, Polygon, Base, Optimism, Arbitrum, Avalanche, Blast, Bnb)
    • 0x0000000000005E88410CcDFaDe4a5EfaE4b49562 on chains supporting the Shanghai hardfork (Scroll, Mantle)
    • 0x000000000000175a8b9bC6d539B3708EEd92EA6c on chains supporting the London hardfork (Linea)

Further Reading: AllowanceHolder Contract