Gasless Swaps - Relay
Gasless Swaps
Gas fees add layers of complexity to swapping. Holding the native token, on the right network, at the right time to pay for gas adds friction for users. A gasless swap means that the user only pays with the input token, and this covers all fees. This means someone else is executing the transaction and paying the gas.
What solution is right for me?
There are many different solutions when it comes to implementing a gasless swap experience. We’ve put together a decision tree below to help you arrive at the solution that best fits your application.
No — BYO wallet
Yes — embedded or custodial
Which gasless flow should I use?
Does your app control the user's wallet?
Permit-based Gasless
Limitation: not all ERC-20s support permit
Are you already using ERC-4337?
ERC-4337 Gasless
7702 BatchExecutor
Same-chain gasless swaps are only supported if you sponsor the fees. Same-chain swaps route directly through DEXes, due to this the solver never has an opportunity to deduct the gas fees before the user gets the destination token.
Permit-based Gasless
Use this approach when your app does not control the user’s wallet (e.g. MetaMask, Rainbow, or any external EOA). The user signs an off-chain EIP-3009 or Permit2 message, and Relay’s solver handles everything else — no approval transaction, no gas.
USDC is fully gasless. Other ERC20 tokens require a one-time approval transaction.
How it works
- Get a quote
Call/quote/v2withusePermit: true - Sign the permit
Prompt the user to sign an EIP-712 typed-data permit message (off-chain, no gas) - Submit to Relay
Submit the signed permit to Relay - Fulfillment
Relay’s solver withdraws tokens from the user’s EOA and fulfills the destination transaction
Fees
You can choose to subsidize all destination fees by passing subsidizeFees: true to the quote api (this effectively subsidizes the first time approval). The user still needs to pay for the origin gas fee. For subsidizing fees you’ll need to make sure you have fee sponsorship set up. See the full working example: byo-eoa-permit
ERC-4337 Gasless
Use this approach if your app already uses ERC-4337 smart accounts. ERC-4337 UserOperations normally require gas fees, either paid by the sender or a paymaster. With Relay, you set all gas fee fields to 0 and submit the handleOps call via Relay’s /execute endpoint instead of directly to the EntryPoint. Relay’s relayer submits the transaction and covers the gas.
originGasOverhead
Pass originGasOverhead: 300000 in the /quote/v2 request. This tells Relay how much additional gas the UserOperation adds over a normal EOA transaction, used during simulation to accurately price the fee.
How it works
- Get a quote
Call/quote/v2withoriginGasOverhead: 300000to get deposit transaction details - Build the UserOperation
Build a UserOperation that batchesapprove+depositcalls viaexecuteBatch - Zero out gas fields
SetmaxFeePerGasandmaxPriorityFeePerGasto0 - Sign the UserOperation
Sign the UserOperation with the account owner key - Submit via Relay
Encode anEntryPoint.handleOps()call and submit it viaPOST /executewithsubsidizeFees: true - Monitor
Poll/intents/status/v3until the bridge completes
Fees
You can choose to subsidize origin fees: pass subsidizeFees: true to the execute api executionOptions. You can choose to subsidize destination fees: pass subsidizeFees: true to the quote api. You can choose to subsidize both or none of these. If not subsidized, the user pays from the output token. For subsidizing fees you’ll need to make sure you have fee sponsorship set up. See the full working example: 4337-gasless
7702 BatchExecutor
Use this approach when your app controls an embedded or custodial wallet and you want gasless execution with any ERC-20 token — not just permit-compatible ones. This leverages EIP-7702 to delegate the user’s EOA to a BatchExecutor contract ( Calibur or similar), enabling atomic approve + deposit in a single call.
originGasOverhead
Pass originGasOverhead: 80000 in the /quote/v2 request. This tells Relay how much additional gas the Calibur execute() wrapper adds over the raw inner calls (EIP-712 signature verification, batch dispatch, nonce check). This is lower than ERC-4337’s 300000 because there’s no EntryPoint or UserOp validation overhead.
The 80000 value is specific to Calibur. Different BatchExecutor contracts may have different gas overheads — adjust this value based on the implementation you use.
How it works
- Check delegation
Check if the user’s EOA is already delegated to the BatchExecutor via EIP-7702 - Get a quote
Call/quote/v2withoriginGasOverhead: 80000to get deposit transaction details - Build the batch
Build aBatchedCallthat atomically combinesapprove()anddeposit() - Sign the authorization
Sign an EIP-7702 authorization (off-chain, no gas) delegating the EOA to the BatchExecutor - Submit via Relay
Submit via POST /execute targeting the user’s EOA
Fees
You can choose to subsidize origin fees: pass subsidizeFees: true to the execute api executionOptions. You can choose to subsidize destination fees: pass subsidizeFees: true to the quote api. You can choose to subsidize both or none of these. If not subsidized the user pays from the output token. For subsidizing fees you’ll need to make sure you have fee sponsorship set up. See the full working example: 7702-batch-executor