For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Contact SupportDiscordGo to dashboard
HomeDocsAPI ReferenceLiquidity IntegrationChangelog
HomeDocsAPI ReferenceLiquidity IntegrationChangelog
  • Introduction
    • Welcome
    • Supported Chains and Providers
    • Demo Apps
    • FAQ
    • API Issues & Error Codes
    • Need Help?
  • Swap API
    • Introduction
    • FAQ
  • Gasless API
    • Introduction
    • Gasless FAQ
  • Cross-Chain API
    • Introduction
    • Learn More
  • Trade Analytics API
    • Introduction
    • Transaction Data
    • Trade Analytics FAQ
  • Core Concepts
    • Introduction to 0x
    • 0x Cheat Sheet
    • Contracts
    • Order Types
    • Glossary
    • White Paper
    • Transaction Data
  • Developer Resources
    • Bounties
    • Rate Limits
    • System Status
  • Upgrading
    • Overview
    • Upgrading to Swap v2
    • Upgrading to Gasless v2
  • Need Help?
    • FAQ
    • API Issues & Error Codes
    • Contact Support
    • Contact Sales
LogoLogo
Contact SupportDiscordGo to dashboard
On this page
  • Overview
  • The Problem
  • The Solution
  • The Benefits of Gasless API
  • Try It Out
  • Supported Chains
  • Learn More
  • Videos
  • Code Examples
  • API Reference
Gasless API

Introduction

||View as Markdown|
Was this page helpful?
Edit this page
Previous

FAQ

Next

Get Started with Gasless API

Built with

Overview

Welcome to 0x’s Gasless API!

Gasless API leverages the 0x relayer network to enable developers to build gasless approvals & swaps into their App & workflows.

The Problem

“Gasless swaps have helped us create a simpler trading experience, where users can focus more on trading and less on network fees. Network fees have been a top pain point for the past few years, and giving users more flexibility around network fees is a huge UX unlock”. - Claudia Haddad, Coinbase Wallet Product Manager.

A major source of friction in web3 is the need for users to hold and maintain balances for each chain’s native token in order to pay for transactions. Before today, users had to overcome this hurdle by preloading wallets, moving balances across apps, and sending tokens between addresses to complete transactions.

This is not only a significant barrier to more widespread adoption, as well as a major source of friction for existing DeFi users when gas spikes, exploring new chains and ecosystems, or trying to make a mobile trade on the go.

The Solution

The Gasless API allows developers to create the smoothest trading experience in DeFi by abstracting away the complexities related to approvals, allowances, and swaps for their users.

Build more intuitive user interfaces and user flows in your applications, improve your conversion funnel drop-offs due to insufficient gas, and set yourself up to easily onboard the next wave of users into web3.

Gasless API Benefits

The Benefits of Gasless API

  • Improve your conversion funnel: Add a gasless fall-back to your existing solution so users aren’t stuck with insufficient gas. Capture more trades when gas is spiking. Become the best places for users to explore DeFi.
  • Build for crypto-native users: Composable with Swap API if you want to offer execution optionality. Devs can design a UX where advanced users can opt in and opt out of gasless without sacrificing experience.
  • Grow your user base with seamless onboarding: Simplify user flows for your app and allow your users to start trading with any token that’s in their wallet. Users won’t be confronted with upfront requests for approvals and network fees, these are abstracted away into the backend.
  • Deep liquidity for the best execution: Unlock aggregated liquidity from 0x private market makers and 100+ exchanges including Uniswap for the most popular pairs on Ethereum, Polygon and Arbitrum.
Gasless API is composable with Swap API

TIP

Want to see a production-level implementation? 👉 Try out the composed Gasless API + Swap API flow live in Matcha Auto at https://matcha.xyz/

Want to see a demo app? 👉 Check out Gasless API Demo App

Try It Out

Run this curl request to see a live quote response for selling 100 USDC to buy WETH:

$// Replace API key in the header with your own key from https://dashboard.0x.org/curl --request GET \ --url 'https://api.0x.org/gasless/quote?chainId=1&sellToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&buyToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&sellAmount=100000000&taker=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' \ --header '0x-api-key: YOUR_API_KEY' \ --header '0x-version: v2'

You will receive a response that looks like this:

Expand to see response
1 {
2 "approval": {
3 "type": "permit",
4 "hash": "0xb55ea370af5b719e1dc1c42b31cd3405acd383040d02a8d1c2802a22a2aee965",
5 "eip712": {
6 "types": {
7 "EIP712Domain": [
8 {
9 "name": "name",
10 "type": "string"
11 },
12 {
13 "name": "version",
14 "type": "string"
15 },
16 {
17 "name": "chainId",
18 "type": "uint256"
19 },
20 {
21 "name": "verifyingContract",
22 "type": "address"
23 }
24 ],
25 "Permit": [
26 {
27 "name": "owner",
28 "type": "address"
29 },
30 {
31 "name": "spender",
32 "type": "address"
33 },
34 {
35 "name": "value",
36 "type": "uint256"
37 },
38 {
39 "name": "nonce",
40 "type": "uint256"
41 },
42 {
43 "name": "deadline",
44 "type": "uint256"
45 }
46 ]
47 },
48 "domain": {
49 "name": "USD Coin",
50 "version": "2",
51 "chainId": 1,
52 "verifyingContract": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
53 },
54 "message": {
55 "owner": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
56 "spender": "0x000000000022d473030f116ddee9f6b43ac78ba3",
57 "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
58 "nonce": 0,
59 "deadline": "1721167909"
60 },
61 "primaryType": "Permit"
62 }
63 },
64 "blockNumber": "20321928",
65 "buyAmount": "26634042862274658",
66 "buyToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
67 "fees": {
68 "integratorFee": null,
69 "zeroExFee": {
70 "amount": "150000",
71 "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
72 "type": "volume"
73 },
74 "gasFee": {
75 "amount": "7901405",
76 "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
77 "type": "gas"
78 }
79 },
80 "issues": {
81 "allowance": {
82 "actual": "0",
83 "spender": "0x000000000022d473030f116ddee9f6b43ac78ba3"
84 },
85 "balance": null,
86 "simulationIncomplete": false,
87 "invalidSourcesPassed": []
88 },
89 "liquidityAvailable": true,
90 "minBuyAmount": "26554140733687834",
91 "route": {
92 "fills": [
93 {
94 "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
95 "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
96 "source": "PancakeSwap_V2",
97 "proportionBps": "10000"
98 }
99 ],
100 "tokens": [
101 {
102 "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
103 "symbol": "USDC"
104 },
105 {
106 "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
107 "symbol": "WETH"
108 }
109 ]
110 },
111 "sellAmount": "99850000",
112 "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
113 "target": "0xca11bde05977b3631167028862be2a173976ca11",
114 "trade": {
115 "type": "settler_metatransaction",
116 "hash": "0xf02495a1a408f0df83afe69902cd9888a390d612b88e03368280bbce144c2658",
117 "eip712": {
118 "types": {
119 "PermitWitnessTransferFrom": [
120 {
121 "name": "permitted",
122 "type": "TokenPermissions"
123 },
124 {
125 "name": "spender",
126 "type": "address"
127 },
128 {
129 "name": "nonce",
130 "type": "uint256"
131 },
132 {
133 "name": "deadline",
134 "type": "uint256"
135 },
136 {
137 "name": "slippageAndActions",
138 "type": "SlippageAndActions"
139 }
140 ],
141 "EIP712Domain": [
142 {
143 "name": "name",
144 "type": "string"
145 },
146 {
147 "name": "chainId",
148 "type": "uint256"
149 },
150 {
151 "name": "verifyingContract",
152 "type": "address"
153 }
154 ],
155 "SlippageAndActions": [
156 {
157 "name": "recipient",
158 "type": "address"
159 },
160 {
161 "name": "buyToken",
162 "type": "address"
163 },
164 {
165 "name": "minAmountOut",
166 "type": "uint256"
167 },
168 {
169 "name": "actions",
170 "type": "bytes[]"
171 }
172 ],
173 "TokenPermissions": [
174 {
175 "name": "token",
176 "type": "address"
177 },
178 {
179 "name": "amount",
180 "type": "uint256"
181 }
182 ]
183 },
184 "domain": {
185 "name": "Permit2",
186 "chainId": 1,
187 "verifyingContract": "0x000000000022d473030f116ddee9f6b43ac78ba3"
188 },
189 "message": {
190 "permitted": {
191 "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
192 "amount": "100000000"
193 },
194 "spender": "0x7c39a136ea20b3483e402ea031c1f3c019bab24b",
195 "nonce": "2241959297937691820908574931991596",
196 "deadline": "1721167608",
197 "slippageAndActions": {
198 "recipient": "0x0000000000000000000000000000000000000000",
199 "buyToken": "0x0000000000000000000000000000000000000000",
200 "minAmountOut": "0",
201 "actions": [
202 "0x0dfeb4190000000000000000000000007c39a136ea20b3483e402ea031c1f3c019bab24b000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000006e898131631616b1779bad70bc2c000000000000000000000000000000000000000000000000000000006696eef8",
203 "0x38c9c147000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000325000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000009f6601854dee374b1bfaf6350ffd27a97309d431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
204 "0x103b48be000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000027100000000000000000000000002e8135be71230c6b1b4045696d41c09db04142260000000000000000000000000000000000000000000000000000000000001901000000000000000000000000000000000000000000000000005e56d9adbf481a"
205 ]
206 }
207 },
208 "primaryType": "PermitWitnessTransferFrom"
209 }
210 },
211 "zid": "0xbfd8e6dd997b9d455f28d595"
212
213}

Supported Chains

Gasless API supports multiple blockchain networks. Refer to the Supported Chains page for the full list of currently supported networks and chain IDs.

Learn More

Videos

Gasless API Explained + Code + Next.js Demo App

Top 10 Gasless API Commonly Asked Questions

Code Examples

  • Gasless API Headless example

API Reference

  • See Swap API reference