> ## Documentation Index
> Fetch the complete documentation index at: https://unevenlabs-scout-mar-1413-gasless-swaps-feature-page-intro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gasless Swaps

> Remove gas friction from swaps so users only pay with the input token

**Gasless Swaps: the token they're swapping is all they need.**

**Users swap with what they hold. Fees come out of the swap, or you cover them.**

Every swap has a hidden prerequisite: gas. Holding the right native token, on the right network, at the right time is friction your users shouldn't have to think about. For users who arrive holding only the token they want to swap, it's a dead end.

Gasless Swaps remove the prerequisite. The user signs, the swap executes, and the input token covers everything: fees come out of the swap itself, so someone holding only USDC can swap it without holding anything else. If you'd rather your users pay nothing at all, cover the fees from your app balance instead.

It keeps the intake side of your product open: users bring whatever token they hold, and you settle in the asset you run on.

## One integration, three paths

Gasless Swaps work with the wallets you already have:

* **External wallets:** The user signs a message offchain and the swap executes from there. No approval transaction, no gas. USDC is fully gasless out of the box; other tokens need a one-time approval.
* **ERC-4337 smart accounts:** Already on smart accounts? Submit the operation through Relay instead of a bundler, and Relay covers the gas.
* **Embedded and custodial wallets:** EIP-7702 delegation makes the approval and the swap one atomic, gasless action with any token.

The decision tree below picks the right path for your setup.

## How it works

1. **Quote:** Request a swap quote as normal.
2. **Sign:** The user signs offchain. No transaction to send, no gas to pay.
3. **Execute:** Relay submits the swap and handles the gas.
4. **Receive:** The user gets the output token, with fees deducted from the swap or covered by you.

## Why it matters

### For integrators

* **Serve users who hold one token.** That's most users, most of the time.
* **Remove the approval-and-gas dance.** One signature replaces the multi-step setup that loses users.
* **Choose the cost model.** Deduct fees from the swap itself, or sponsor them for a free experience.
* **Skip paymaster and bundler infrastructure.** The paths above all use one API.

### For your users

* **Swap what they hold.** No native gas token required.
* **Sign once.** No approval transaction, setup, or dead end.

## Who it's for

* **Wallets and wallet infrastructure:** Make the swap button work for users who hold a single token.
* **Onchain apps:** Keep users swapping with the balance they already have instead of stalling when they run out of gas.
* **DEXes and aggregators:** Offer routes users can complete, whatever token they hold.

## What to watch

Same-chain Gasless Swaps require you to sponsor the fees. Same-chain swaps route directly through DEXes, so Relay cannot deduct gas fees before the user receives the destination token. On the external-wallet path, tokens without permit support need a one-time approval transaction.

For stablecoin conversions at exactly 1:1, pair Gasless Swaps with [Price Stabilization](/features/price-stabilization) and [Fee Sponsorship](/features/fee-sponsorship).

***

## What solution is right for me?

There are many different solutions when it comes to implementing a gasless swap experience. We've put together a decision tree below to help you arrive at the solution that best fits your application.

```mermaid placement="top-right" theme={null}
flowchart TD
    Start([Which gasless flow should I use?]) --> WalletControl
    WalletControl{Does your app control<br/>the user's wallet?}
    WalletControl -->|No — BYO wallet| Permit
    WalletControl -->|Yes — embedded or custodial| Has4337
    Has4337{Are you already<br/>using ERC-4337?}
    Has4337 -->|Yes| Smart4337
    Has4337 -->|No| BatchExecutor

    Permit[/"**Permit-based Gasless**<br/><br/>_Limitation: not all ERC-20s support permit_"/]
    Smart4337[/"**ERC-4337 Gasless**"/]
    BatchExecutor[/"**7702 BatchExecutor**"/]

    click Permit "#permit-based-gasless" _blank
    click Smart4337 "#erc-4337-gasless" _blank
    click BatchExecutor "#7702-batchexecutor" _blank

    style Permit fill:#f9e3e3,stroke:#c44,color:#000
    style Smart4337 fill:#e3e9f9,stroke:#44c,color:#000
    style BatchExecutor fill:#e3f9e6,stroke:#4a4,color:#000

```

<Warning>
  Same-chain gasless swaps are only supported if you sponsor the fees. Same-chain swaps route directly through DEXes, due to this the solver never has an opportunity to deduct the gas fees before the user gets the destination token.
</Warning>

## Permit-based Gasless

Use this approach when your app does **not** control the user's wallet (e.g. MetaMask, Rainbow, or any external EOA). The user signs an off-chain EIP-3009 or Permit2 message, and Relay's solver handles everything else — no approval transaction, no gas.

<Warning>
  USDC is fully gasless. Other ERC20 tokens require a one-time approval transaction.
</Warning>

### How it works

<Steps>
  <Step title="Get a quote">
    Call `/quote/v2` with `usePermit: true`
  </Step>

  <Step title="Sign the permit">
    Prompt the user to sign an EIP-712 typed-data permit message (off-chain, no gas)
  </Step>

  <Step title="Submit to Relay">
    Submit the signed permit to Relay
  </Step>

  <Step title="Fulfillment">
    Relay's solver withdraws tokens from the user's EOA and fulfills the destination transaction
  </Step>
</Steps>

### Fees

You can choose to subsidize all destination fees by passing `subsidizeFees: true` to the quote api (this effectively subsidizes the first time approval). The user still needs to pay for the origin gas fee. For subsidizing fees you'll need to make sure you have [fee sponsorship](/features/fee-sponsorship) set up.

*See the full working example: [<Icon icon="github" size={16} /> byo-eoa-permit](https://github.com/relayprotocol/relay-gasless-examples/tree/main/byo-eoa-permit)*

***

## ERC-4337 Gasless

Use this approach if your app already uses ERC-4337 smart accounts. ERC-4337 UserOperations normally require gas fees, either paid by the sender or a paymaster. With Relay, you set all gas fee fields to 0 and submit the `handleOps` call via Relay's [/execute](/references/api/execute) endpoint instead of directly to the EntryPoint. Relay's relayer submits the transaction and covers the gas.

### `originGasOverhead`

Pass **`originGasOverhead: 300000`** in the `/quote/v2` request. This tells Relay how much additional gas the UserOperation adds over a normal EOA transaction, used during simulation to accurately price the fee.

### How it works

<Steps>
  <Step title="Get a quote">
    Call `/quote/v2` with `originGasOverhead: 300000` to get deposit transaction details
  </Step>

  <Step title="Build the UserOperation">
    Build a UserOperation that batches `approve` + `deposit` calls via `executeBatch`
  </Step>

  <Step title="Zero out gas fields">
    Set **`maxFeePerGas`** and **`maxPriorityFeePerGas`** to `0`
  </Step>

  <Step title="Sign the UserOperation">
    Sign the UserOperation with the account owner key
  </Step>

  <Step title="Submit via Relay">
    Encode an `EntryPoint.handleOps()` call and submit it via `POST /execute` with `subsidizeFees: true`
  </Step>

  <Step title="Monitor">
    Poll `/intents/status/v3` until the bridge completes
  </Step>
</Steps>

### Fees

You can choose to subsidize origin fees: pass `subsidizeFees: true` to the execute api `executionOptions`.

You can choose to subsidize destination fees: pass `subsidizeFees: true` to the quote api.

You can choose to subsidize both or none of these. If not subsidized the user pays from the output token.

For subsidizing fees you'll need to make sure you have [fee sponsorship](/features/fee-sponsorship) set up.

*See the full working example: [<Icon icon="github" size={16} /> 4337-gasless](https://github.com/relayprotocol/relay-gasless-examples/tree/main/4337-gasless)*

***

## 7702 BatchExecutor

Use this approach when your app controls an embedded or custodial wallet and you want gasless execution with **any** ERC-20 token — not just permit-compatible ones. This leverages EIP-7702 to delegate the user's EOA to a BatchExecutor contract ([Calibur](https://github.com/Uniswap/calibur) or similar), enabling atomic approve + deposit in a single call.

### `originGasOverhead`

Pass **`originGasOverhead: 80000`** in the `/quote/v2` request. This tells Relay how much additional gas the Calibur `execute()` wrapper adds over the raw inner calls (EIP-712 signature verification, batch dispatch, nonce check). This is lower than ERC-4337's `300000` because there's no EntryPoint or UserOp validation overhead.

<Info>
  The `80000` value is specific to [Calibur](https://github.com/Uniswap/calibur). Different BatchExecutor contracts may have different gas overheads — adjust this value based on the implementation you use.
</Info>

### How it works

<Steps>
  <Step title="Check delegation">
    Check if the user's EOA is already delegated to the BatchExecutor via EIP-7702
  </Step>

  <Step title="Get a quote">
    Call `/quote/v2` with `originGasOverhead: 80000` to get deposit transaction details
  </Step>

  <Step title="Build the batch">
    Build a `BatchedCall` that atomically combines `approve()` and `deposit()`
  </Step>

  <Step title="Sign the authorization">
    Sign an EIP-7702 authorization (off-chain, no gas) delegating the EOA to the BatchExecutor
  </Step>

  <Step title="Submit via Relay">
    Submit via POST [/execute](/references/api/execute) targeting the user's EOA
  </Step>
</Steps>

### Fees

You can choose to subsidize origin fees: pass `subsidizeFees: true` to the execute api `executionOptions`.

You can choose to subsidize destination fees: pass `subsidizeFees: true` to the quote api.

You can choose to subsidize both or none of these. If not subsidized the user pays from the output token.

For subsidizing fees you'll need to make sure you have [fee sponsorship](/features/fee-sponsorship) set up.

*See the full working example: [<Icon icon="github" size={16} /> 7702-batch-executor](https://github.com/relayprotocol/relay-gasless-examples/tree/main/7702-batch-executor)*
