> ## Documentation Index
> Fetch the complete documentation index at: https://docs.biconomy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Gasless Token Swaps

> Execute token swaps without paying gas fees

Swap tokens without users needing ETH or native tokens for gas. Biconomy handles gas abstraction—users can pay fees in the token they're swapping, or you can sponsor gas entirely.

## How It Works

<Steps>
  <Step title="User Initiates Swap">
    User selects tokens and amount to swap
  </Step>

  <Step title="API Finds Best Route">
    Biconomy finds optimal route across DEXs and bridges
  </Step>

  <Step title="User Signs Once">
    Single signature approves the entire swap—no separate gas transaction
  </Step>

  <Step title="MEE Executes">
    Biconomy relayers execute and pay gas, deducting fee from swap or your sponsorship
  </Step>
</Steps>

## Quick Example

Swap 100 USDC on Base to USDT on Optimism—completely gasless:

```typescript theme={null}
// 1. Request a quote
const quote = await fetch('https://api.biconomy.io/v1/quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    mode: 'smart-account',
    ownerAddress: '0xYourAddress',
    // No feeToken = sponsored (gasless)
    composeFlows: [{
      type: '/instructions/intent-simple',
      data: {
        srcChainId: 8453,           // Base
        dstChainId: 10,             // Optimism
        srcToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',  // USDC
        dstToken: '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58',  // USDT
        amount: '100000000',        // 100 USDC (6 decimals)
        slippage: 0.01              // 1%
      }
    }]
  })
}).then(r => r.json());

// 2. Sign the payload
const signature = await wallet.signMessage({
  message: quote.payloadToSign[0].signablePayload.message
});

// 3. Execute
const result = await fetch('https://api.biconomy.io/v1/execute', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    ...quote,
    payloadToSign: [{ ...quote.payloadToSign[0], signature }]
  })
}).then(r => r.json());

console.log('Track at:', `https://meescan.biconomy.io/details/${result.supertxHash}`);
```

## Two Ways to Go Gasless

<Tabs>
  <Tab title="Sponsored (You Pay)">
    **Best for:** Onboarding flows, premium users, promotional campaigns

    Omit the `feeToken` parameter—gas is paid from your sponsorship account:

    ```typescript theme={null}
    {
      mode: 'smart-account',
      ownerAddress: userAddress,
      // No feeToken = use sponsorship
      composeFlows: [...]
    }
    ```

    <Note>
      Requires an API key with sponsorship enabled. Get one at [dashboard.biconomy.io](https://dashboard.biconomy.io)
    </Note>
  </Tab>

  <Tab title="User Pays in Token">
    **Best for:** Regular transactions where users cover costs

    Set `feeToken` to deduct gas from the token being swapped:

    ```typescript theme={null}
    {
      mode: 'smart-account',
      ownerAddress: userAddress,
      feeToken: {
        address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', // USDC
        chainId: 8453
      },
      composeFlows: [...]
    }
    ```

    User still signs once—fee is automatically deducted from their USDC.
  </Tab>
</Tabs>

## Works with Any Wallet

<CardGroup cols={2}>
  <Card title="Smart Accounts" icon="wallet">
    Use `mode: 'smart-account'` for Nexus or ERC-4337 accounts. Native gas abstraction.
  </Card>

  <Card title="EOA Wallets" icon="key">
    Use `mode: 'eoa'` for MetaMask, Rabby, etc. Requires `fundingTokens` parameter.
  </Card>
</CardGroup>

### EOA Example (MetaMask, Rabby, etc.)

```typescript theme={null}
const quote = await fetch('https://api.biconomy.io/v1/quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    mode: 'eoa',
    ownerAddress: userAddress,
    fundingTokens: [{
      tokenAddress: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
      chainId: 8453,
      amount: '100000000'
    }],
    feeToken: {
      address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
      chainId: 8453
    },
    composeFlows: [{
      type: '/instructions/intent-simple',
      data: {
        srcChainId: 8453,
        dstChainId: 10,
        srcToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
        dstToken: '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58',
        amount: '100000000',
        slippage: 0.01
      }
    }]
  })
}).then(r => r.json());
```

## Understanding the Response

The quote response tells you exactly what will happen:

```json theme={null}
{
  "fee": {
    "amount": "50000",           // Fee in token units
    "token": "0x833589...",      // Fee token address
    "chainId": 8453
  },
  "returnedData": [{
    "outputAmount": "99500000",  // Expected output
    "minOutputAmount": "98505000", // After slippage
    "route": {
      "summary": "lifi[uniswap] => across",
      "estimatedTime": 120
    }
  }]
}
```

| Field             | What It Means                           |
| ----------------- | --------------------------------------- |
| `fee.amount`      | How much gas costs (in fee token units) |
| `outputAmount`    | Expected tokens user will receive       |
| `minOutputAmount` | Minimum after slippage protection       |
| `route.summary`   | Which DEXs/bridges will be used         |

## Next Steps

<CardGroup cols={2}>
  <Card title="Cross-Chain Swaps" icon="globe" href="/swaps-trading/cross-chain-swap">
    Deep dive into multi-chain swap mechanics
  </Card>

  <Card title="Full API Tutorial" icon="book" href="/overview/supertransaction-api">
    Learn the complete quote → sign → execute flow
  </Card>
</CardGroup>
