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.
How It Works
- User requests a protected API - standard GET/POST to an x402-enabled endpoint
- Backend returns HTTP 402 - with x402 v2 payment requirements including
relayerContractanddomainNameinextra - One-time approve (first payment only) - user approves the relayer contract to spend USDC
- User signs EIP-712 authorization - a single off-chain signature with the A402 domain
- 0xGasless verifies and settles - relayer executes the transfer on-chain, paying gas
- User gets the API response - seamless access, zero gas fees
Supported Networks
| Network | Chain ID | Token | Relayer Contract | Gas |
|---|---|---|---|---|
| Avalanche C-Chain | 43114 | USDC | 0x457Db7ce...cEdC8 | Free (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.
- Check allowance
- MetaMask popup: approve (~$0.01 AVAX)
- Sign EIP-712 authorization
- Payment settled
- Sign EIP-712 authorization
- Payment settled
Technical Details
| Property | Value |
|---|---|
| Facilitator URL | https://x402.0xgasless.com(proxied via RelAI) |
| x402 Version | v2 |
| EIP-712 Domain Name | A402 |
| EIP-712 Domain Version | 1 |
| Avalanche Relayer | 0x457Db7ceBAdaF6A043AcE833de95C46E982cEdC8 |
| Avalanche USDC | 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E |
| validAfter | 0 (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 gasDashboard 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
validAfteris0(not a timestamp) - Check EIP-712 domain uses
name: "A402"andverifyingContract: 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