Gasless Cross-Chain Transactions
Gasless solves main Web3 barrier: users need native tokens on each chain to pay gas. Want Arbitrum? Need ETH on Arbitrum. Want Base? Need ETH on Base. Bad UX. Gasless cross-chain goes further: user doesn't think about gas AND doesn't think about being on specific chain.
Components
Layer 1: Meta-transactions / ERC-4337. Who pays gas on source chain.
Layer 2: Paymaster. Sponsor covering gas or accepting ERC-20 payment.
Layer 3: Cross-chain relayer. Who transmits message and pays gas on destination.
Layer 4: Solver/intent executor. Finds optimal execution route.
ERC-4337 as Foundation
Without ERC-4337 each gasless scheme — custom hack. With ERC-4337 — standardized framework:
interface UserOperation {
sender: string;
nonce: bigint;
initCode: string;
callData: string;
callGasLimit: bigint;
verificationGasLimit: bigint;
preVerificationGas: bigint;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
paymasterAndData: string;
signature: string;
}
Bundler collects UserOperations, packs into transaction, submits on-chain. Bundler pays gas and gets reimbursed from paymaster or user account.
Paymaster Implementation
Paymaster decides "who pays gas":
contract ERC20Paymaster is BasePaymaster {
address public acceptedToken;
AggregatorV3Interface public priceFeed;
function _validatePaymasterUserOp(
UserOperation calldata userOp,
bytes32 userOpHash,
uint256 maxCost
) internal override returns (bytes memory context, uint256 validationData) {
uint256 tokenAmount = _calculateTokenAmount(maxCost);
tokenAmount = tokenAmount * 110 / 100; // 10% buffer
require(
IERC20(acceptedToken).allowance(userOp.sender, address(this)) >= tokenAmount,
"Insufficient token allowance"
);
return (abi.encode(userOp.sender, tokenAmount), 0);
}
function _postOp(
PostOpMode mode,
bytes calldata context,
uint256 actualGasCost
) internal override {
(address sender, uint256 maxTokenAmount) = abi.decode(context, (address, uint256));
uint256 actualTokenAmount = _calculateTokenAmount(actualGasCost);
IERC20(acceptedToken).transferFrom(sender, address(this), actualTokenAmount);
}
}
Cross-Chain Gas Relay
Who pays gas on destination?
Axelar Gas Service: prepay gas for destination in native token on source:
function sendGaslessMessage(
string calldata destChain,
string calldata destContract,
bytes calldata payload
) external payable {
gasService.payNativeGasForContractCall{value: msg.value}(
address(this), destChain, destContract, payload, msg.sender
);
gateway.callContract(destChain, destContract, payload);
}
LayerZero with gas drop: airdrop native gas on destination address:
function sendWithGasDrop(
uint16 dstChainId,
bytes calldata payload,
address payable refundAddress,
address zroPaymentAddress,
uint256 dstNativeAmount,
address dstNativeAddress
) external payable {
bytes memory adapterParams = abi.encodePacked(
uint16(2),
uint256(200000),
dstNativeAmount,
dstNativeAddress
);
lzEndpoint.send{value: msg.value}(
dstChainId,
abi.encode(destContract),
payload,
refundAddress,
zroPaymentAddress,
adapterParams
);
}
Custom relayer network: own relayer nodes holding native token balances on all chains.
Intent-Based Gasless
Most advanced: user signs intent, solver executes and profits from arbitrage:
interface GaslessIntent {
user: string;
sourceChain: number;
destChain: number;
action: string;
inputToken: string;
inputAmount: string;
minOutputAmount: string;
deadline: number;
signature: string;
}
class IntentSolver {
async solve(intent: GaslessIntent): Promise<void> {
const route = await this.findOptimalRoute(intent);
const expectedOutput = await this.simulate(route, intent);
const gasCosts = await this.estimateTotalGasCosts(route);
const profit = expectedOutput - BigInt(intent.minOutputAmount) - gasCosts;
if (profit < this.minProfitThreshold) return;
await this.executeRoute(route, intent);
}
}
Permit2 for Gasless Approvals
Traditional approve requires separate transaction (gas). With Permit2 (Uniswap):
const permit = {
permitted: { token: USDC_ADDRESS, amount: parseUnits("100", 6) },
spender: RELAYER_ADDRESS,
nonce: await getPermitNonce(userAddress),
deadline: Math.floor(Date.now() / 1000) + 3600,
};
const signature = await signer._signTypedData(
{ name: "Permit2", chainId: 1, verifyingContract: PERMIT2_ADDRESS },
PERMIT2_TYPES,
permit
);
await permit2Contract.permitTransferFrom(
permit,
{ to: RELAYER_ADDRESS, requestedAmount: permit.permitted.amount },
userAddress,
signature
);
Economics
Who pays in the end?
| Model | Payer | When |
|---|---|---|
| Sponsored (freemium) | App | Onboarding, gaming, loyalty |
| ERC-20 paymaster | User in stablecoin | DeFi, trading |
| Solver extracts surplus | Solver from arbitrage | Intent-based protocols |
| Fee token swap | System converts | General case |
Stack
Smart contracts: Solidity + ERC-4337 + Permit2 + Foundry. Bundler: Pimlico, StackUp, Alchemy or Alto. Paymaster: custom ERC20Paymaster. Cross-chain: Axelar Gas Service or LayerZero. Relayer: Node.js + viem. Frontend: wagmi v2 + permissionless.js.
Timelines
- Gasless single chain (ERC-4337 + paymaster): 3-4 weeks
- Cross-chain gas relay (Axelar/LayerZero): +3-4 weeks
- Intent solver: +4-6 weeks
- Production + monitoring + audit: +4-6 weeks
- Total: 3-4 months







