Overview
Gasless transactions let users pay network fees using ERC-20 tokens (USDC, USDT) instead of requiring native gas (ETH, MATIC). This eliminates a major friction point—users don’t need to hold the native token on every chain.| Benefit | How It Works |
|---|---|
| No native gas required | Users pay fees in stablecoins or other ERC-20 tokens |
| Better UX | No “insufficient gas” errors for users with only stablecoins |
| Permit signatures | EIP-2612 permits enable gasless token approvals |
| Flexible fee options | SDK shows available fee token options automatically |
How Gasless Works
Trails supports two approaches for gasless transactions:- ERC-20 Fee Tokens (Default) — Users sign a permit, and Trails’ relayer submits the transaction. The fee is deducted from the user’s ERC-20 balance.
- 4337 Paymasters — For apps with their own paymaster infrastructure, Trails can route through ERC-4337 bundlers.
Basic Gasless Payment
When using the SDK, gasless fee options are automatically displayed if the user’s origin token supports permits:- Shows fee options including “Pay gas in USDC”
- Requests a permit signature (no approval transaction needed)
- Submits via relayer—user’s USDC covers the gas fee
USDC/USDT as Gas Fee Examples
Pay with USDC on Polygon
Pay with USDT on Polygon
Cross-Chain Gasless
Even cross-chain payments can be gasless if the origin token supports permits:Permit-Compatible Tokens
Gasless transactions require tokens that implement EIP-2612 (permit):| Token | Permit Support | Notes |
|---|---|---|
| USDC | ✓ | Native Circle USDC on all supported chains |
| USDT | ✓ | Most chains (verify per-chain) |
| DAI | ✓ | Supports permit on Ethereum, L2s |
| WETH | ✓ | Wrapped ETH supports permit |
| Most ERC-20s | Varies | Check if token has permit() function |
Native tokens (ETH, MATIC, etc.) cannot be used for gasless since they don’t support permits. Users paying with native tokens will use standard gas.
How Fee Options Work
The SDK automatically fetches available fee options based on:- User’s token balances on the origin chain
- Which tokens support permit signatures
- Current gas prices and token exchange rates
- ETH (native gas)
- USDC ($0.12)
- USDT ($0.12)
Programmatic Fee Selection
You can listen to fee option events:4337 Paymaster Integration
For apps with existing paymaster infrastructure (Alchemy, Pimlico, ZeroDev, Thirdweb), configure per-chain paymaster URLs:Supported Paymaster Providers
| Provider | Notes |
|---|---|
| Alchemy | Uses bundler-only mode (no separate paymaster client) |
| Pimlico | Full paymaster + bundler support |
| ZeroDev | Full paymaster + bundler support |
| Thirdweb | Full paymaster + bundler support |
When using
paymasterUrls, the paymaster sponsors the gas entirely. Users don’t pay any fee—the app/merchant absorbs it.Gasless Flow Details
Without Paymaster (ERC-20 Fees)
- Quote Intent — SDK fetches quote including
gasFeeOptionswith available fee tokens - User Selects Fee — User picks USDC, USDT, or native gas from dropdown
- Permit Signature — If ERC-20 fee selected, user signs EIP-2612 permit (no on-chain tx)
- Intent Signature — User signs the intent data
- Relayer Submits — Trails relayer executes the transaction, deducting fee from user’s balance
- Completion — User receives confirmation once destination transaction confirms
With Paymaster (4337)
- Prepare UserOp — SDK prepares ERC-4337 user operation
- Paymaster Sponsorship — Paymaster adds
paymasterAndDatato sponsor gas - User Signs — User signs the user operation
- Bundler Submits — Bundler submits to entry point
- Completion — User receives confirmation
Limitations
Smart Contract Wallets: Gasless deposits via permit signatures require EOA (externally owned account) wallets. Smart contract wallets produce non-standard signatures that the current relayer doesn’t support.Best Practices
Let Users Choose
Let Users Choose
Don’t force gasless. Some users prefer paying native gas (often cheaper at low congestion). The SDK shows both options by default.
Handle Signature Rejections
Handle Signature Rejections
Users might reject the permit signature. Handle this gracefully:
Verify Permit Support
Verify Permit Support
Not all ERC-20 tokens support permits. The SDK automatically filters to show only valid fee options, but for API integrations, check token contracts.
Paymaster Security
Paymaster Security
If using custom paymasters:
- Validate paymaster URLs are HTTPS
- Use separate paymaster URLs per environment (dev/prod)
- Monitor paymaster spending and set limits
- Consider allowlisting user operations by contract/method
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| No ERC-20 fee options shown | Token doesn’t support permit | User must pay native gas |
| ”Smart contract wallets not supported” | SC wallet detected | Use native gas flow |
| Permit signature fails | Token permit implementation varies | Try a different token or native gas |
| Paymaster rejects UserOp | Paymaster policy/limits | Check paymaster configuration |