FrameGas

Pay gas in any ERC20, natively. EIP-8141 paymaster priced on Uniswap v4, via the alt mempool.

FrameGas

Created At

ETHGlobal Mumbai

Project Description

FrameGas lets an account that only holds an ERC20 (a stablecoin, a governance token, an agent's USDC budget) send any transaction on Ethereum without ever touching ETH. You sign one EIP-8141 frame transaction. The paymaster's validation frame reads the token price from a Uniswap v4 pool and checks your cap, balance and allowance. Its settlement frame pulls the token, swaps it for ETH on the same pool and pays the gas. Your call runs. A last frame refunds whatever token wasn't used. All of it is atomic, so if any frame fails nothing moves.

This only works in the alternative mempool. Send the same signed bytes to the canonical mempool and it comes back with StorageReadNonSender, because the paymaster reads pool state during validation. The alt mempool lets it in because the paymaster is staked.

What's in the repo: the paymaster with 44 contract tests and a 10,000 run fuzz; a bootstrap mode that handles a user's very first transaction in a single tx with no precompile and no relayer; a per account daily quota enforced in validation; a TypeScript SDK (framegas.send({payToken, maxTokenCost, calls})) that simulates first and sizes every frame; an MCP server so agents can pay their own gas from a token budget; a Skill in the Uniswap AI format; a Chainlink CRE workflow for price sanity bounds; a demo with replay and live modes; and docs/findings.md with what I learned about how the devnet's rules differ from ERC-8421, including a 100k shared validation cap for staked entities, disabled precompiles (filed as forshtat/mempool-workshop#1), the state gas cost of crossing a tick for the first time, and what it costs to grief a paymaster that prices from a pool.

Measured on the devnet: a normal transaction costs the user 1.04x the gas fee in tokens with a 1.17x reserve. The first transaction per token costs about 0.56 fgUSD more because of the allowance slot. The paymaster can lose at most 0.002 ETH on any single transaction.

Limitations: EIP-8141 ships in Hegotá, so this runs on the EF alt mempool devnet (chain 1337) only. The stake is locked for good. Permit deadlines have to be max uint because TIMESTAMP is banned in validation. Thin pools make a failed settlement cheap to force, so I enforce a minimum liquidity check at admission.

How it's Made

Contracts are Foundry, Solidity 0.8.26, no upgradeability. FrameGasPaymaster stakes itself from its own constructor because the registry keys on msg.sender. Validation is a single extsload of slot0 through Uniswap's StateLibrary, a balance and allowance read, and some arithmetic. That's 45k gas, and it has to fit inside a 100k cap shared across every validation frame. I measured that cap live: 100,000 was admitted, 100,001 was rejected.

NUMBER, TIMESTAMP, BASEFEE and GASPRICE are all banned in validation. So the deviation check compares against a reference tick the paymaster keeps in its own storage and advances during settlement, with a permissionless syncReference() that's rate limited per block so a big market move can't brick it. Gas price comes from the signed transaction itself. Validation also pins the next frame to settle() on this paymaster, with the exact calldata shape, zero value and a minimum gas limit, so every griefing path I found fails at admission instead of after the paymaster has already paid.

Settlement swaps on a native ETH v4 pool from my own unlock callback, no router. I went native because mainnet's ETH/USDC pool is about seven orders of magnitude deeper than WETH/USDC. Each tick crossed adds roughly 24.5k gas, and crossing a tick for the first time ever needs around 196k of state gas, so the SDK simulates first, searches for state gas and then execution gas per frame, tightens the limits, and re-simulates the whole thing before signing.

Bootstrap mode exists because the devnet sidecar runs with precompiles: [], which means ecrecover gets rejected in validation even though OP-062 and CALLING-040 both allow it. Rather than relay a permit, I let the user's first transaction carry a user frame that validation forces to be exactly approve(paymaster, n >= cap), with settlement running after it. One tx, zero ETH, no precompile.

The devnet is ethrex on the eip8141 tracer branch with the sidecar from forshtat/mempool-workshop. Uniswap v4 core, Permit2 and Universal Router were already deployed there; I seeded my own native ETH/fgUSD pool at mainnet's price. The Chainlink CRE workflow runs in simulation and compares the devnet pool against mainnet. The demo is Next.js with a replay mode driven by recorded admission reports and receipts, which turned out to matter because the devnet halted for hours mid hackathon.

The hacky bits: the stake can never be withdrawn (there's no owner, on purpose). Permit deadlines are max uint. The minimum liquidity threshold is set low on devnet and labelled as such. The explorer forgets everything when the node restarts, so I screenshot evidence into docs/evidence/.

I used AI coding assistants (Claude) for implementation. Architecture, rule analysis, security decisions and all testing were reviewed by me.

background image mobile

Join the mailing list

Get the latest news and updates