Decentralized ERC-4337 paymaster enabling cross-chain gasless transactions via liquidity pools.

Open Paymaster is a decentralized, trustless paymaster built on ERC-4337 that enables gasless blockchain transactions through community-funded liquidity pools.
The frustrating problem:
Users face three fundamental barriers when using Ethereum-compatible networks:
Why Centralized Paymasters available today Don't Solve This:
A proposed solution
Open Paymaster enables users to pay transaction fees with any supported ERC-20 token. Liquidity providers earn yield on native ETH deposits, while users get seamless access without ever touching gas tokens.
How It Works:
Complementation with EIL
Open Paymaster strongly complements the Ethereum Interoperability Layer (EIL) to achieve a truly unified Ethereum experience. While EIL CrossChainPaymaster covers gas on destination chains, the Open Paymaster covers the gas on the origin chain. Together, these systems eliminate the need to maintain ETH balances across multiple chains or trust centralized intermediaries.
Example:
Alice has 100 USDC on Ethereum mainnet. She wants to send 50 USDC to Bob on Base. Neither of them has or understands what gas is.
Traditional approach (broken UX):
With Open Paymaster + EIL:
Neither Alice nor Bob needed to understand gas, acquire native tokens, or trust centralized services.
Key Properties:
Trustless: No reliance on centralized operators Permissionless: Anyone can become a liquidity provider Gasless UX: Users pay fees in tokens they already hold ERC-4337 native: Built on the account abstraction standard Cross-chain ready: Integrates with EIL for multi-chain operations
`The system is built in Solidity with Foundry as the development framework. The OpenPaymaster contract inherits from three base contracts: BasePaymaster (ERC-4337 interface), EntryPointVault (ERC-6909 multi-token vault for LP share accounting), and PythOracleAdapter (Pyth Network price feed integration).
The contract defines three roles: Liquidity Providers deposit ETH and earn fees, Users pay gas in tokens, and Rebalancers arbitrage token accumulation to keep pools balanced.
SYSTEM COMPONENTS
Open Paymaster: Singleton on-chain contract holding all liquidity pools. Handles token-to-gas conversion, gas sponsorship, and LP share management.
Paymaster Router (optional): Off-chain service that queries all pools for a given token and returns the cheapest option. Example: "I want to pay in USDC, which pool gives me the best rate right now?"
Frontend (optional): Next.js web app providing fallback UI for liquidity providers to deposit, withdraw, and rebalance pools. Also serves as a fallback for users whose wallets don't support Open Paymaster yet, enabling cross-chain gasless transactions directly through the web interface.
HOW A TRANSACTION WORKS
When a user wants to pay gas in USDC instead of ETH:
User signs a permit allowing the paymaster to transfer tokens (gasless approval using EIP-2612)
User submits a UserOperation with paymasterData encoding the token address and Pyth price update data
Validation phase (_validatePaymasterUserOp): Verifies the pool exists and has sufficient ETH reserves Queries cached token/ETH price from Pyth oracle Calculates conservative prefund estimate including LP fees and rebalancing fees Transfers tokens from user to paymaster Returns context data for postOp
EntryPoint executes the user's transaction, sponsored by the paymaster's ETH
PostOp phase (_postOp): Updates Pyth price feeds with fresh off-chain data Recalculates actual gas cost using current prices Refunds excess tokens to user Updates pool accounting (decreases ETH reserves, increases token reserves)
The two-phase pricing (cached for validation, fresh for settlement) prevents MEV and ensures users pay fair market rates while giving bundlers predictable validation.
POOL MANAGEMENT
Anyone can initialize a new token pool by calling initializePool with token address, Pyth feed ID, LP fee (basis points), and rebalancing fee (basis points). The contract uses ERC-6909 to track LP shares per pool, encoding the pool ID as uint256(uint160(tokenAddress)).
Liquidity providers deposit ETH by calling deposit() with a specific pool ID. They receive ERC-6909 shares representing their portion of that pool's ETH reserves. Withdrawals burn shares and return proportional ETH.
REBALANCING MECHANISM
As users pay gas in tokens, pools accumulate tokens and deplete ETH reserves. The rebalance() function allows anyone to buy accumulated tokens at a discount (the rebalancingFeeBps). This creates an arbitrage opportunity: rebalancers deposit ETH, extract tokens below market price, and resell them elsewhere for profit. This keeps pools healthy without requiring active management.
PYTH ORACLE INTEGRATION
Pyth provides pull-based price feeds where off-chain price data is submitted on-chain only when needed. The paymaster stores two feed IDs: ETH/USD and the token's feed ID. During validation, we use the cached on-chain price. During postOp, we update both feeds with signed price data from Pyth's off-chain service and pay the update fee from the paymaster's balance.
EIL CROSS-CHAIN INTEGRATION
For cross-chain transactions, Open Paymaster handles origin chain gas while EIL's CrossChainPaymaster handles destination chain gas. A user paying USDC on Ethereum to send funds to Base only signs once. The origin transaction is sponsored by Open Paymaster (paid in USDC), which creates an EIL voucher request. An XLP fulfills the voucher on Base, and the destination transaction executes gaslessly from the user's perspective.
FRONTEND & SDK
The frontend is Next.js 14 with TypeScript, using wagmi and viem for wallet interaction. The SDK abstracts the complexity: developers call paymasterClient.estimateUserOpGas(token) and the SDK queries Pyth feed IDs, fetches current prices, encodes paymasterData, and constructs the UserOperation.
The system is fully permissionless with no admin keys, upgrade mechanisms, or pause functionality. Anyone can create pools, provide liquidity, or rebalance without permission.

