Gasless API FAQ
What chains does Gasless API support?
See the full list of supported chains.
What tokens are supported?
Gasless API offers gasless approvals and gasless swaps for supported tokens.
For gasless approvals:
- Generally, these are tokens that support EIP-2612. In otherwords, these are ERC-20s with the Permit function
- You can also examine if a token supports gasless approvals at trade time, by observing the response from requests to /gasless/quote. If the
approval
object is not null, it will contain the necessary information to process a gasless approval
For gasless swaps, all tokens are supported following sell token lists are supported.
Note, the only trades Gasless API CANNOT support are those where end-user is trying to sell a native token from their wallet (e.g. selling ETH on Mainnet, or selling MATIC on Polygon). This is because native tokens are typically not ERC-20s, so they do not support the transferFrom
function, which the metatransaction relay system underlying Gasless API utilizes. In this case, we’d recommend using the Swap API, wherein the user will pay for the gas of the transaction, with the chain’s native token. Otherwise, you can recommend your users to wrap their ETH into WETH (or equivalent, in other chains).
Who pays for the gas fees to allow those swaps to happen?
0x covers the gas fee up front. This cost is then wrapped into the trade and paid for in the form of the token the user is trading.
Applications may choose to sponsor transactions, in which case they will pay 0x directly, and users will not be billed on chain
Can I monetize using Gasless API?
You have full flexibility on the fees you collect on your trades.
Setup requires including the following three parameters when making a Gasless API request:
swapFeeRecipient
 - The wallet address to receive the specified trading fees.swapFeeBps
 - The amount in Bps (Basis points) of theswapFeeToken
to charge and deliver to theswapFeeRecipient
. Denoted as an integer between 0 - 1000 where 1000 Bps represents 10%.swapFeeToken
- The contract address of the token to receive trading fees in. This must be set to either the value ofbuyToken
or thesellToken
.
https://api.0x.org/gasless/quote // Request a firm quote
?chainId=1 // Ethereum Mainnet
&sellToken=0x6B175474E89094C44Da98b954EedeAC495271d0F // Sell DAI
&sellAmount=4000000000000000000000 // Sell amount: 4000 (18 decimal)
&buyToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE // Buy ETH
&taker=$USER_TAKER_ADDRESS // Address that will make the trade
&swapFeeRecipient=$INTEGRATOR_WALLET_ADDRESS // Wallet address that should receive the affiliate fees
&swapFeeBps=100 // Percentage of buyAmount that should be attributed as affiliate fees
&swapFeeToken=0x6B175474E89094C44Da98b954EedeAC495271d0F // Receive trading fee in sellToken (DAI)
--header '0x-api-key: [API_KEY]' // Replace with your own API key
--header '0x-version: v2' // API version
What if my user wants to sell a native token, e.g. swap ETH for USDC, on Mainnet?
In this case, we’d recommend using the Swap API, wherein the user will pay for the gas of the transaction, with the chain’s native token. Otherwise, you can recommend your users to wrap their ETH into WETH (or equivalent, in other chains).
What tokens work with gasless approvals?
To check if a token supports gasless approvals, you can also examine if a token supports gasless approvals at trade time, by observing the response from requests to /gasless/quote. If the approval
object is not null, it will contain the necessary information to process a gasless approval.
Generally, these are tokens that support EIP-2612. In otherwords, these are ERC-20s with the Permit functionGenerally, these are tokens that support EIP-2612. In otherwords, these are ERC-20s with the Permit function
What if my user is selling a token that doesn’t support gasless approvals?
In this case, your user would need to do a standard approval transaction with Permit2. See intructions for how to set token allowance. If you user doesn’t have sufficient native token to pay for the approval transaction, they can use Gasless API to swap a popular token (e.g. USDC) for ETH (or the equivalent native token) on Mainnet, MATIC on Polygon, etc. Please note that the approval transaction is a one-time transaction for each new token the user sells. Once the approval transaction is mined, the user can still do gasless swaps with that token.
Some UIs may choose not to support tokens that do not support EIP-2612 to be able to guarantee a 100% gasless experience. However, Gasless API does not limit anyone in this manner and is strictly a choice of the developer.
How do I know if an approval is required?
Check the response from /gasless/quote
,
- If the
issues.allowance
object is not null, an allowance approval is required - If the
approval
object is returned is not null, then a gasless approval is possible
My user is doing a swap and needs an approval - are these separate transactions? Do I need 2 signatures?
Although gasless approvals and gasless swap are bundled in the same transaction, they each require a signature for the corresponding EIP-712 object. However, you may elect to create a front-end experience wherein it appears to the user that they are signing only 1 transaction.
What does a gasless approve + swap happy path look like, using Gasless API?
See the flow charts here.
What is the minimum amount users can trade with Gasless API?
The minimum amount will vary across chains, trade sizes and current gas conditions. When attempting to trade an amount that is too small, the API response will return an error message with the estimated minimum amount for that trade. In general, we recommend setting a minimum of $10 on Mainnet, and $1 on other chains for the best experience.
I received one of these error messages: INPUT_INVALID, BUY_TOKEN_NOT_AUTHORIZED_FOR_TRADE, INTERNAL_SERVER_ERROR. Help!
Read more about Status Codes.