Gasless Payments

0xGasless Facilitator

Gasless x402 payments on EVM networks using a custom relayer contract and EIP-712 authorization

0xGasless is a third-party gasless payment facilitator for EVM networks. It uses a custom relayer contract that verifies off-chain EIP-712 signatures and executes token transfers on behalf of the user, paying all gas fees.

$0
Zero Gas Fees
0xGasless relayer pays all transaction gas
1x
Signature Only
Users sign a single EIP-712 typed data message

How It Works

  1. User requests a protected API - standard GET/POST to an x402-enabled endpoint
  2. Backend returns HTTP 402 - with x402 v2 payment requirements including relayerContract and domainName in extra
  3. One-time approve (first payment only) - user approves the relayer contract to spend USDC
  4. User signs EIP-712 authorization - a single off-chain signature with the A402 domain
  5. 0xGasless verifies and settles - relayer executes the transfer on-chain, paying gas
  6. User gets the API response - seamless access, zero gas fees

Supported Networks

NetworkChain IDTokenRelayer ContractGas
Avalanche C-Chain43114USDC0x457Db7ce...cEdC8Free (AVAX)

Custom EIP-712 Domain

Unlike standard USDC transferWithAuthorization (which uses the USDC contract as verifyingContract), 0xGasless defines its own EIP-712 domain:

// 0xGasless EIP-712 Domain (Avalanche example)
{
  name: "A402",
  version: "1",
  chainId: 43114,
  verifyingContract: "0x457Db7ceBAdaF6A043AcE833de95C46E982cEdC8"
}

The signed message type is TransferWithAuthorization:

TransferWithAuthorization {
  from:        address   // payer wallet
  to:          address   // merchant wallet (payTo)
  value:       uint256   // amount in atomic units
  validAfter:  uint256   // always 0 for 0xGasless
  validBefore: uint256   // expiration timestamp
  nonce:       bytes32   // random 32-byte nonce
}

Important: The validAfter field must always be 0 (not a timestamp). This is a 0xGasless-specific requirement.

One-Time ERC-20 Approve

Before the first payment, users must approve the relayer contract to spend their USDC. This is a standard ERC-20 approve call and only needs to happen once per token per network.

// Approve relayer contract (one-time, ~$0.01 gas)
USDC.approve(
  "0x457Db7ceBAdaF6A043AcE833de95C46E982cEdC8",  // relayer contract
  type(uint256).max                                 // unlimited
)

The RelAI frontend handles this automatically - if allowance is insufficient, it prompts the user for approval before proceeding with the payment.

Applies to AI agents too. The relayer contract uses transferFrom internally, so every wallet - whether a browser wallet (MetaMask) or an AI agent wallet - must approve the relayer contract before its first payment. Agents should call USDC.approve(relayerContract, maxUint256) once during wallet setup.

First Payment
  1. Check allowance
  2. MetaMask popup: approve (~$0.01 AVAX)
  3. Sign EIP-712 authorization
  4. Payment settled
Subsequent Payments
  1. Sign EIP-712 authorization
  2. Payment settled

Technical Details

PropertyValue
Facilitator URLhttps://x402.0xgasless.com(proxied via RelAI)
x402 Versionv2
EIP-712 Domain NameA402
EIP-712 Domain Version1
Avalanche Relayer0x457Db7ceBAdaF6A043AcE833de95C46E982cEdC8
Avalanche USDC0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
validAfter0 (always zero)

SDK Integration

The RelAI SDK (@relai-fi/x402) automatically detects when relayerContract is present in payment requirements and signs with the correct 0xGasless domain. No changes needed in client code:

import { createX402Client } from '@relai-fi/x402'

const client = createX402Client({
  evmWallet: {
    address: userAddress,
    signTypedData: wallet.signTypedData,
  }
})

// 0xGasless domain is detected and used automatically
const response = await client.fetch('https://your-api.com/data')
// Payment handled: user signs once, 0xGasless pays gas

Dashboard Configuration

On the RelAI dashboard, select 0xGasless as your facilitator and Avalanche as the network:

{
  network: "avalanche",
  facilitator: "0xgasless",
  pricing: {
    "GET /data": { amount: "10000" }  // $0.01 USDC (6 decimals)
  }
}

Troubleshooting

"Invalid signature" from /verify

  • Ensure validAfter is 0 (not a timestamp)
  • Check EIP-712 domain uses name: "A402" and verifyingContract: relayerContract
  • Verify the SDK version supports 0xGasless domain detection

Settlement transaction reverts

  • Check USDC balance on user wallet
  • Verify ERC-20 allowance for the relayer contract: USDC.allowance(user, relayerContract)
  • If allowance is 0, the user needs to approve the relayer contract first