Skip to main content

Understanding Gasless API

This guide contains information about how Gasless API works, key terms, and technical flow charts for how to implement in-app.

How does it work?

A major source of friction in Web3 is the need for users to hold a small amount of the chain's native token to pay for token approvals and subsequent transactions (aka paying "gas" fees).

Gasless API can provide a gasless approval and gasless swap experience for supported ERC-20 token swaps (read more in "What tokens are supported?").

This API returns liquidity—prices and quotes—to end users. If a user is happy with a quote the API has provided, they can sign an EIP-712 message for the approval and trade. Then, Gasless API can submit the transaction to the blockchain on behalf of the user, eliminating the need for the end user to pay for gas manually.

The term "gasless" refers to the ability for users to trade without needing to pay the gas cost at that moment. Instead, a third party like 0x can submit the transaction(s) to the blockchain and pay the gas fee. So, in practice, there is still gas involved—it's just being paid by someone else. The user doesn't have to worry about holding the chain's native token in order to pay for gas cost upfront when submitting a transaction. A suggested implementation is to use Gasless API to pay for the gas on behalf of the user with the trade's input token (sell token).

Key Terms

Token Allowances

A token allowances is required if you want a third-party to move funds on your behalf. In short, you are allowing them to move your tokens. In our case, we would like the 0x Exchange Proxy smart contract to trade our ERC20 tokens for us, so we need to write to the ERC20 contract of that token, and approve an allowance for 0x Exchange Proxy (i.e. allow it to move a certain amount of tokens on our behalf us).

For tokens that do not support gasless approvals, we needed to set the token allowance via the messages listed here.

EIP-712: Human Readable Messages

EIP-712 is the standard for typed message signing. This EIP allows wallets to display data in signing prompts in a human readable and not just a blind hash.

Gasless leverages EIP-712 messages to enable gasless approvals and gasless transactions.

EIP-2612: Gasless Approvals

EIP-2612 unlocked gasless token approvals by introducting a new Permit function to ERC-20 tokens. The Permit function enables enables users to grant permission to others to spend their tokens in a single transaction which offer more efficient token approvals and enabled gasless transactions.

Meta Transactions

Meta Transactions are messages that authorize smart contracts to perform actions on your behalf.

Gasless Approvals

Gasless approvals is possible when the user signs a EIP-712 message giving Gasless API permission to set an allowance on the token required for approval. In the current architecture 0x or the market maker pays for this gas fee, and the user has a “gasless” experience. This is possible for tokens that support the Permit Extension (EIP-2612).

Gasless Transactions

By integrating Gasless API, your app can support gasless transactions — in which the user signs a EIP-712 message giving Gasless API permission to submit a transaction on behalf of the user to the blockchain. This is possible with Meta Transactions. In the current architecture, Gasless pays for the gas of the transaction using some of the user’s sell token.

Meta Transaction V2

This represents one of two types of gasless transactions returned by the Gasless API /quote endpoint. Meta Transaction V2 leverages the Swap API to fetch indicative pricing and quotes. 0x submits these transactions to the blockchain on behalf of the user.


This represents the other type of transaction returned by the Gasless API /quote endpoint. OTC transactions allow market makers to provide indicative pricing and quotes. In these transactions, a market maker submits the transaction to the blockchain on behalf of the user.

Technical Flow Charts

Gasless API Flow

Below is an image showing the ideal path when implementing both gasless approvals and gasless swaps using the Gasless API. Click here to expand the image.

Gasless Approval + Gasless Swaps Flow Happy Path

Composing Gasless API + Swap API

Gasless API is composable with Swap API if you want to offer execution optionality (e.g. offering "vanilla" swaps for tokens that Gasless API does not support). Devs can design a UX where advanced users can opt in and opt out of gasless without sacrificing experience. Click here to expand the image

Composing Gasless Approval + Gasless Swaps + Swap API Happy Path


Want to see a live implementation of Gasless API + Swap API? Try out the flow in the Matcha Auto feature 👉