Skip to content

About

Reproducible gas benchmarks: ERC-4337 UserOperations vs EOA transactions (SimpleAccount, Safe, Kernel, EIP-7702, paymasters)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

ERC-4337 gas benchmarks

On an Anvil fork of Ethereum mainnet at block 26,377,620, a USDC transfer sent as an ERC-4337 UserOperation from an already-deployed smart account used 125,249 to 155,229 gas, against 45,136 gas for the same transfer sent from an EOA: 2.8 to 3.4 times as much, or about 80,000 to 110,000 extra gas. An ETH transfer went from 21,000 gas to 107,609 to 137,594 gas. The first operation of a new contract account, which deploys it, used 312,000 to 453,013 gas; the first operation of an EIP-7702 account used 161,580 gas. A paymaster added about 22,000 gas for sponsorship (verifying mode) and about 55,000 to 59,000 gas when the user pays gas in USDC (ERC-20 mode). Batching helps: 5 USDC transfers in one UserOperation used 177,380 to 212,072 gas, less than the 225,680 gas of 5 EOA transactions, and 5 UserOperations from 5 accounts in one bundle cost 86,193 gas per operation instead of 132,811 for a single one.

These are the numbers from results/results.json, produced by pnpm bench in this repo. They reproduce the controlled benchmark on Pimlico's docs page ERC-4337 gas overhead vs regular transactions to within 24 gas (see Comparison with the docs page).

Results

One UserOperation per handleOps transaction unless noted. Gas is the bundle transaction's receipt gasUsed, which is the full onchain cost of the operation. Each value is the median of 3 runs. The full generated report is in results/results.md.

Summary

Action EOA transaction ERC-4337 UserOperation Ratio
ETH transfer, account already deployed 21,000 107,609 – 137,594 5.1× – 6.6×
USDC transfer, account already deployed 45,136 125,249 – 155,229 2.8× – 3.4×
USDC transfer, first operation (deploys the account) 45,136 312,000 – 453,013 6.9× – 10.0×
USDC transfer, first operation of an EIP-7702 account 45,136 161,580 3.6×
5 USDC transfers (5 EOA transactions vs 1 batched UserOperation) 225,680 177,380 – 212,072 0.79× – 0.94×
Paymaster added to a USDC transfer: sponsorship (verifying mode) – +22,022 – +22,329 –
Paymaster added to a USDC transfer: user pays gas in USDC (ERC-20 mode) – +54,809 – +59,300 –

The ranges cover four accounts: Simple7702Account (EIP-7702) at the low end, then SimpleAccount, Safe and Kernel.

By account (self-paid)

Account EntryPoint ETH transfer USDC transfer First operation: deploy + USDC transfer Batch of 5 USDC transfers in one operation
EOA (regular transaction) – 21,000 45,136 – 225,680 (5 transactions)
Simple7702Account (EIP-7702) v0.8 107,609 125,249 161,580 (delegation, no deployment) 177,380
SimpleAccount v0.7 114,855 132,811 312,000 188,437
Safe 1.4.1 + Safe4337Module v0.7 135,377 153,516 453,013 208,597
Kernel v3.1 (ECDSA validator) v0.7 137,594 155,229 352,661 212,072

Paymaster overhead

USDC transfer from an already-deployed account, with Pimlico's singleton paymaster contracts as deployed on mainnet (0x777777777777AeC03fd955926DbF81597e66834C for EntryPoint v0.7, 0x888888888888Ec68A58AB8094Cc1AD20Ba3D2402 for v0.8).

Account Self-paid Verifying paymaster (sponsored) ERC-20 paymaster (gas paid in USDC)
Simple7702Account (EntryPoint v0.8) 125,249 147,271 (+22,022) 180,058 (+54,809)
SimpleAccount (EntryPoint v0.7) 132,799 155,128 (+22,329) 192,099 (+59,300)

A verifying paymaster adds its paymasterAndData to the calldata, a call that checks its signer's signature, and deposit accounting in the EntryPoint. An ERC-20 paymaster also runs postOp and moves the fee in USDC from the account to the paymaster's treasury, which is a second token transfer.

Several UserOperations in one bundle

Bundle Gas Per operation
1 SimpleAccount USDC-transfer operation 132,811 132,811
5 SimpleAccount USDC-transfer operations from 5 accounts 430,965 86,193

Where the gas goes

USDC transfer from an already-deployed account, split with Anvil's debug_traceTransaction call tracer. Validation is the gas used inside the account's validateUserOp; execution is the gas used inside the EntryPoint's call to the account that runs the transfer; the remainder is the EntryPoint's own work (nonce, hashing, prefund and refund accounting, events, bundler payment) and the cost of the calls between contracts.

Component Simple7702Account SimpleAccount Safe Kernel
Transaction base cost 21,000 21,000 21,000 21,000
Calldata of the bundle transaction 5,928 (900 bytes) 5,940 (900 bytes) 6,068 (932 bytes) 6,108 (900 bytes)
Account validation (validateUserOp) 4,344 11,982 25,772 50,448
Execution (the USDC transfer, through the account) 27,067 28,033 34,796 28,556
EntryPoint and call overhead (remainder) 66,910 65,856 65,880 49,117
Total 125,249 132,811 153,516 155,229

The same USDC transfer from an EOA used 45,136 gas: 21,000 base cost, 584 gas of calldata (68 bytes) and 23,552 gas of execution.

Comparison with the docs page

Account Scenario This repo Docs page Difference
EOA ETH transfer 21,000 21,000 +0
EOA USDC transfer 45,136 45,136 +0
Simple7702Account ETH transfer 107,609 107,609 +0
Simple7702Account USDC transfer 125,249 125,237 +12
Simple7702Account First op + USDC transfer 161,580 161,568 +12
Simple7702Account Batch of 5 USDC transfers 177,380 177,368 +12
Simple7702Account Verifying paymaster 147,271 147,259 +12
Simple7702Account ERC-20 paymaster 180,058 180,070 −12
SimpleAccount ETH transfer 114,855 114,855 +0
SimpleAccount USDC transfer 132,811 132,799 +12
SimpleAccount First op + USDC transfer 312,000 311,988 +12
SimpleAccount Batch of 5 USDC transfers 188,437 188,425 +12
SimpleAccount Verifying paymaster 155,128 155,128 +0
SimpleAccount ERC-20 paymaster 192,099 192,099 +0
SimpleAccount Bundle of 5 operations 430,965 430,965 +0
Safe ETH transfer 135,377 135,377 +0
Safe USDC transfer 153,516 153,528 −12
Safe First op + USDC transfer 453,013 453,037 −24
Safe Batch of 5 USDC transfers 208,597 208,585 +12
Kernel ETH transfer 137,594 137,582 +12
Kernel USDC transfer 155,229 155,217 +12
Kernel First op + USDC transfer 352,661 352,673 −12
Kernel Batch of 5 USDC transfers 212,072 212,048 +24

Every number is within 24 gas of the docs page, and validation, execution and remainder match exactly; the differences are all in calldata. Calldata costs 4 gas per zero byte and 16 per non-zero byte, so each byte that happens to be zero in one run and non-zero in another (in an ECDSA signature or in the maxFeePerGas field, which follows the fork's base fee) moves the total by 12 gas. Repeat runs in this repo differ by up to 36 gas for the same reason.

Not reproduced here: the docs page's onchain sample (median gas and dollar fees of real UserOperations and EOA transfers on Ethereum mainnet, Base and Arbitrum). That part comes from reading UserOperationEvent logs over a day of chain history, not from a controlled benchmark, so it is out of scope for this repo. All controlled-benchmark scenarios on the page are reproduced.

Method

  • Anvil (Foundry 1.8.4) forks Ethereum mainnet at block 26,377,620 (9 November 2026, 13:25 UTC).
  • Accounts are built with viem 2.57.17 and permissionless 0.5.2: toSimpleSmartAccount, toSafeSmartAccount (1.4.1 with Safe4337Module), toKernelSmartAccount (v3.1, ECDSA validator) on EntryPoint v0.7 (0x0000000071727De22E5E9d8BAf0edAc6f37da032), and viem's toSimple7702SmartAccount on EntryPoint v0.8 (0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108), delegating to Simple7702Account at 0xe6Cae83BdE06E4c305530e199D7217f42808555B.
  • Each UserOperation is signed with fixed gas limits and sent by an EOA in its own handleOps transaction (except the 5-operation bundle). The EIP-7702 authorization is included in the first bundle transaction. Receipt gas does not depend on the gas limits.
  • The script checks that every transaction and every UserOperationEvent succeeded, and records gasUsed from the receipt.
  • USDC comes from a whale impersonated on the fork. Every recipient already holds ETH and USDC, so no transfer creates a new balance.
  • After its first operation each account gets a 1 ETH deposit in the EntryPoint (a setup transaction that is not measured), so steady-state operations never send a missing prefund during validation. A prefund transfer adds about 8,700 gas; the script flags any run where it happens. First operations do pay their prefund, as they would in practice.
  • Paymasters: the singleton paymasters only accept signatures from addresses in their signers mapping. On the fork the script finds that mapping's storage slot and sets a test signer to true with anvil_setStorageAt. The paymaster contracts and their code are the ones deployed on mainnet. The ERC-20 mode uses an exchange rate of 2,118 USDC per ETH and pays the fee to a treasury address that already holds USDC.
  • Test keys are derived from fixed labels, so every run uses the same addresses. Anvil's well-known account #0 is the bundler. No real keys are used.

Code: src/scenarios.ts (what is measured), src/lib.ts (building, sending and tracing operations), src/run.ts (starts Anvil and writes results), src/report.ts (markdown tables).

How to run

Requirements: Node.js 20 or later, pnpm, and Foundry (anvil on your PATH). You need an Ethereum mainnet RPC that serves archive state for block 26,377,620.

pnpm install
ETH_RPC_URL=https://your-archive-rpc pnpm bench

pnpm bench starts anvil --fork-url $ETH_RPC_URL --fork-block-number 26377620 on port 8645 (change it with ANVIL_PORT), runs every scenario, and writes results/results.json (every run, with transaction hash, gas and the component split) and results/results.md. To use a fork you started yourself, set ANVIL_RPC_URL instead of ETH_RPC_URL. A run takes a few minutes, most of it fetching fork state from the RPC.

The committed results were produced with the public endpoint https://eth.drpc.org, which served archive state for this block at the time of writing.

Other commands: pnpm report regenerates results/results.md from results/results.json, and pnpm typecheck runs the TypeScript compiler.

About

Maintained by Pimlico. Pimlico runs Alto, an open-source ERC-4337 bundler. Background on where the overhead comes from and how to reduce it is on the docs page.

License

MIT

About

Reproducible gas benchmarks: ERC-4337 UserOperations vs EOA transactions (SimpleAccount, Safe, Kernel, EIP-7702, paymasters)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages