📜 ERC-4337 Spec: UserOps & Bundlers

Understand how account abstraction works under the hood

Explore EIP-4337 and the future of wallets

ERC-4337 Specification

**ERC-4337** is the standard that enables account abstraction without requiring changes to Ethereum's consensus layer. It introduces a new object called **UserOperation**—a pseudo-transaction that describes what the user wants to do. These UserOps flow through a separate mempool to bundlers, who package them into actual transactions.

The beauty of ERC-4337 is its compatibility: it works on any EVM chain today, leverages existing security assumptions, and enables innovation at the application layer without waiting for protocol upgrades.

Interactive: UserOperation Flow

Watch how a UserOperation flows through the ERC-4337 architecture from user to execution.

📝

UserOperation

User signs intent to execute operation

Key Components:
sender
nonce
callData
signature
gasLimits
📦

Bundler

Aggregates multiple UserOps into one transaction

🎯

EntryPoint

Validates and routes UserOperations

👛

Smart Wallet

Executes the actual operation

💰

Paymaster (Optional)

Sponsors gas fees for the user

📋 UserOperation Structure

A UserOperation contains all information needed to execute an operation on behalf of the user:

struct UserOperation {
address sender; // Smart wallet address
uint256 nonce; // Anti-replay protection
bytes initCode; // Wallet creation code (if needed)
bytes callData; // Function call to execute
uint256 callGasLimit; // Gas for main execution
uint256 verificationGasLimit;
uint256 preVerificationGas;
uint256 maxFeePerGas;
uint256 maxPriorityFeePerGas;
bytes paymasterAndData; // Paymaster info (optional)
bytes signature; // User's signature
}

Key Components Deep Dive

🎯 EntryPoint Contract (0x5FF...000)

Singleton contract that validates and executes all UserOperations. Think of it as the universal entry point for all AA wallets.

handleOps(UserOperation[] ops, address beneficiary)

📦 Bundlers

Specialized nodes that collect UserOps from alt-mempool, simulate execution, bundle multiple ops, and submit to EntryPoint. They get refunded for gas + take a small fee.

Example: Stackup, Alchemy, Biconomy bundlers

👛 Smart Contract Wallets

Must implement IAccount interface with validateUserOp() function. This is where custom logic lives: multisig, social recovery, spending limits, etc.

function validateUserOp(UserOperation op, bytes32 userOpHash, uint256 missingAccountFunds)

💰 Paymasters

Optional contracts that sponsor gas fees. Can accept ERC-20 tokens, implement subscription models, or provide free transactions for marketing.

function validatePaymasterUserOp(UserOperation op, bytes32 userOpHash, uint256 maxCost)

🔐 Security Guarantees

  • Replay Protection: Nonce prevents same UserOp from executing twice
  • Gas Griefing Prevention: Bundlers simulate ops before submission, reject invalid ones
  • DoS Protection: Reputation system bans misbehaving wallets/paymasters
  • Censorship Resistance: Multiple bundlers compete, users can run their own

Why Not Change Ethereum Protocol?

ERC-4337 achieves account abstraction at the application layer, avoiding consensus changes. This means:

✓ Faster Deployment
Live today on all EVM chains, no hard fork needed
✓ Easier Iteration
Can upgrade EntryPoint without protocol changes
✓ Lower Risk
Issues don't affect core consensus layer
✓ Innovation Space
Anyone can build custom wallets and paymasters