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

# Gasless Relayer

> Let the taker sign Permit2 while Rialto submits the swap and pays gas.

## Overview

The gasless flow lets the taker sign Permit2 while Rialto submits the onchain swap
transaction. The taker still authorizes the exact swap with a Permit2 witness
signature, but the relayer wallet pays the network gas.

## Constraints

| Constraint   | Behavior                                                                              |
| ------------ | ------------------------------------------------------------------------------------- |
| Settlement   | Requires settlement: permit2 and a returned permit2 payload.                          |
| Token type   | ERC20 sells only. Native ETH sells require the taker-submitted flow.                  |
| Permit owner | Pass permit2\_owner=taker on the quote. For gasless, permit2\_owner must equal taker. |
| Recipient    | The quote controls the recipient through the Permit2 witness. Do not edit it.         |
| Allowance    | The taker must still approve Permit2 if issues.allowance is non-null.                 |
| Balance      | Do not submit if issues.balance is non-null.                                          |

## Step 1: request a gasless quote

Add permit2\_owner to the standard quote request:

```bash theme={null}
API_KEY='rialto_live_example.redacted_secret'
TAKER='0x1111111111111111111111111111111111111111'

curl -sS "https://rialto-trade-api.rialto.xyz/quote?sell_token=USDC&buy_token=ARB&sell_amount=1&taker=$TAKER&permit2_owner=$TAKER&slippage_bps=50&chain_id=42161" \
  -H "Authorization: Bearer $API_KEY"
```

The response includes quote\_id, the permit2 typed data, issues, and the tx Rialto
will submit after receiving the signature.

## Step 2: approval and signature

If issues.allowance is non-null, the taker approves issues.allowance.spender for
at least the raw sell\_amount. For gasless Permit2 quotes the spender is the
Permit2 contract. Then have the taker sign the permit2 typed data exactly as
returned.

## Step 3: submit to the relayer

```http theme={null}
POST /gasless/submit
```

Auth: requires an API key with swap access.

| Field            | Description                                                                                                                                                                                                                   |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| quote\_id        | UUID returned by the quote. The quote must have been requested with permit2\_owner.                                                                                                                                           |
| signature        | 0x-prefixed 65-byte Permit2 signature over the typed data returned by the quote.                                                                                                                                              |
| idempotency\_key | Optional client-generated unique string for one relay attempt, such as your internal order id or a UUID. Reuse the same value only when retrying the same quote submission; do not reuse it across different quotes or users. |

```bash theme={null}
curl -sS 'https://rialto-trade-api.rialto.xyz/gasless/submit' \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "quote_id": "b7b0a3d8-9f6a-4f4a-92d2-1b0e4b5d0c6a",
    "signature": "0xabc123...",
    "idempotency_key": "partner-order-123"
  }'
```

Example response:

```json theme={null}
{
  "relay_id": "f3f6a35f-93b9-4629-9a2e-02d2b80648ef",
  "quote_id": "b7b0a3d8-9f6a-4f4a-92d2-1b0e4b5d0c6a",
  "status": "submitted",
  "chain_id": 42161,
  "tx_hash": "0x6b8f...",
  "error": null
}
```

## Step 4: poll relay status

```http theme={null}
GET /gasless/status/{relay_id}
```

Auth: requires an API key with swap access.

| Status    | Meaning                                                         |
| --------- | --------------------------------------------------------------- |
| accepted  | Request accepted and queued.                                    |
| submitted | Relayer broadcasted the transaction.                            |
| confirmed | Transaction mined successfully.                                 |
| failed    | Transaction was submitted but failed or could not be confirmed. |
| expired   | Request expired before successful relay.                        |
| rejected  | Request failed validation before relay.                         |

```bash theme={null}
curl -sS 'https://rialto-trade-api.rialto.xyz/gasless/status/f3f6a35f-93b9-4629-9a2e-02d2b80648ef' \
  -H "Authorization: Bearer $API_KEY"
```

A full runnable Python example for the gasless flow is in the API repo:
[https://github.com/rialto-plds/rialto-api-docs/blob/main/RIALTO\_SWAP\_API.md](https://github.com/rialto-plds/rialto-api-docs/blob/main/RIALTO_SWAP_API.md)
