Gasless Transactions Implementation (Paymaster) in Crypto App
Main barrier for crypto app mass adoption — gas. New user installed app, created wallet, got USDC from friend. Wants to send — told "You have 0 ETH for commission fee." Funnel ends. Gasless transactions via Paymaster solve this: gas sponsored by app or paid with ERC-20 token instead of native.
How ERC-4337 and Paymaster Work
Account Abstraction (ERC-4337) introduces UserOperation — structure replacing regular transaction. Bundler collects UserOperations from mempool and sends to EntryPoint contract in batch. Paymaster — separate smart contract taking gas payment when its logic satisfied.
Two main Paymaster types:
- Sponsoring Paymaster: app pays gas for users free
- Token Paymaster: user pays in ERC-20 (USDC, USDT) instead of ETH
// UserOperation with Paymaster via Biconomy SDK
import { createSmartAccountClient } from "@biconomy/account";
import { createPaymaster } from "@biconomy/paymaster";
const paymaster = await createPaymaster({
paymasterUrl: "https://paymaster.biconomy.io/api/v2/137/YOUR_API_KEY"
});
const smartAccount = await createSmartAccountClient({
signer: walletSigner,
bundlerUrl: "https://bundler.biconomy.io/api/v2/137/YOUR_API_KEY",
paymaster: paymaster
});
// Send transaction — user doesn't pay ETH
const tx = await smartAccount.sendTransaction({
to: recipientAddress,
data: encodeFunctionData({ ... }),
value: 0n
});
On mobile client user just clicks "Confirm" — biometrics (Face ID / Fingerprint), transaction sent. No ETH balance, no gas question.
Integration into iOS/Android App
For native apps without React Native Account Abstraction logic moved to server side — mobile client sends request to backend, backend forms UserOperation, signs via user's smart account and sends to Bundler. Mobile client only passes transaction data and gets result.
// iOS: gasless transaction request via own backend
struct GaslessTransactionRequest: Encodable {
let action: String // "transfer", "mint", "swap"
let params: [String: Any]
let userSmartAccount: String
}
class TransactionService {
func sendGasless(request: GaslessTransactionRequest) async throws -> TransactionResult {
let response = try await apiClient.post(
"/transactions/gasless",
body: request
)
// Polling or WebSocket to get txHash
return try await pollTransactionStatus(response.operationId)
}
}
Backend stores smart account keys in HSM or via Privy Server Wallets / Fireblocks API — no private keys on mobile device.
Limitations and Abuse Prevention
Gas sponsoring is money. Without limits botnet empties Paymaster balance in hours. Necessary measures:
Rate limiting. Maximum N gasless transactions per day per user. At Paymaster contract level — check via lastTxTime[sender] mapping with minimum interval.
Whitelist actions. Paymaster sponsors only certain calls — e.g., only transfer() of specific token, not arbitrary contracts.
App Check verification. Verify request from legitimate app via Firebase App Check (uses DeviceCheck on iOS, Play Integrity on Android). Without valid App Check token backend doesn't form UserOperation.
// Paymaster contract: whitelist functions
function _validatePaymasterUserOp(
UserOperation calldata userOp,
bytes32,
uint256
) internal view override returns (bytes memory, uint256) {
bytes4 selector = bytes4(userOp.callData[:4]);
require(allowedSelectors[selector], "Function not sponsored");
require(dailyUsage[userOp.sender] < MAX_DAILY_OPS, "Daily limit exceeded");
return ("", 0);
}
Paymaster Balance and Monitoring
Paymaster holds deposit on EntryPoint contract. When deposit runs out — transactions start failing with AA31 paymaster deposit too low. Need balance monitoring via EntryPoint.getDepositInfo(paymasterAddress) and auto top-up via Chainlink Automation or simple cron worker.
Worth setting dashboard: transactions per day, average gas, total costs. Biconomy Dashboard, Alchemy Gas Manager Dashboard — ready solutions if using their infrastructure.
Provider Selection
| Provider | Supported Networks | Features |
|---|---|---|
| Biconomy | 50+ networks | SDK for React Native, JS |
| ZeroDev | Ethereum, Polygon, Arbitrum | Kernel account, simple API |
| Alchemy Gas Manager | 10+ networks | Integrated with Alchemy RPC |
| Pimlico | Most EVM | Good bundler, Token Paymaster |
| Own | Any EVM | Full control, higher complexity |
For production app with > 10K DAU — recommend own Paymaster on Ethereum L2 (Base, Arbitrum, Optimism): gas 90% cheaper vs mainnet, but full control over sponsorship logic.
Timeline
5–7 days for integration via ready provider (Biconomy/ZeroDev) with server-side UserOperation logic. 2–3 weeks for own Paymaster with custom sponsorship rules and monitoring. Cost calculated individually after requirements analysis.







