RoadToChain Logo
RoadToChain
T4/M4.3/ERC-4337 explained
advanced 15m read

ERC-4337 explained

EntryPoint execution, alternative UserOperations mempools, and the low-level account abstraction standard.

#erc4337 #account-abstraction #diagram

Implementing smart contract wallets historically required changing the consensus rules of the Ethereum network (which is extremely slow) or running complex, centralized relayers.

ERC-4337 solved this by introducing Account Abstraction without consensus changes, creating a standard for smart contract execution routing.


1. Layman Explanation: The Corporate Travel Assistant

To understand how ERC-4337 works under the hood, let's look at a corporate expense analogy.

Imagine you are a busy company executive who needs to travel frequently:

  • The Traditional EOA Way: Every time you want to book a flight, secure a hotel, or buy a coffee, you have to personally pull out your wallet, swipe your credit card, enter your PIN, and manually collect the receipt. If you lose your physical card, you are completely locked out of your corporate funds. Furthermore, you must carry local currency (gas) for every minor purchase en route.
  • The ERC-4337 Way: You don't carry a physical credit card. Instead, you have an Executive Assistant (your Smart Account contract). When you want to book a trip, you don't execute the transaction yourself. You write a signed request slip (a UserOperation) detailing your intent: "I authorize booking flight #104." You hand this slip to your assistant.

Behind the scenes:

  1. Your assistant doesn't call the airline directly. They hand your request slip (and request slips from other executives) to a Consolidated Travel Agency (the Bundler).
  2. The agency aggregates all these slips from the alternative mailroom (the alt-mempool), packages them into a single massive itinerary, and pays the airline in bulk using one corporate check (a standard EVM transaction).
  3. The check is processed by the Company Finance Department (the EntryPoint contract), which verifies that the signature on each request slip is valid, and that the department has enough budget (the Paymaster) deposited to sponsor the trip so you don't pay out of pocket.

This is exactly how ERC-4337 operates: you sign a simple intention offline, the network infrastructure bundles and executes it for you, and a sponsor pays your gas fees.


2. The Core Architecture

ERC-4337 introduces four key components to the Web3 transaction pipeline:

  1. UserOperation (UserOp): A pseudo-transaction object representing the user's intent (like "call this contract with this data"). It is signed by the user's validation key but is not a standard transaction.
  2. Bundler: A node that gathers multiple UserOperation objects from an alternative mempool (alt-mempool), aggregates them, and bundles them into a single standard EVM transaction.
  3. EntryPoint Contract: A singleton, audited smart contract on the blockchain that acts as the coordinator for all ERC-4337 executions. Bundlers call the handleOps function on this contract.
  4. Smart Account: The user's contract wallet, which must implement the IAccount interface. It validates the UserOp signature and executes the internal payload.

// The ERC-4337 transaction pipeline: User signers broadcast UserOps to alt-mempools, Bundlers pack them, and EntryPoint contracts handle validation and execution.


3. The Two-Phase Execution Loop

When a Bundler submits a bundle to the EntryPoint contract, the EntryPoint executes a strict two-phase loop:

Phase 1: Validation (validateUserOp)

The EntryPoint calls validateUserOp on each Smart Account in the bundle.

  • The Smart Account checks the signature on the UserOp.
  • If a Paymaster is defined, the EntryPoint checks that the Paymaster has deposited enough gas tokens to cover the operation.
  • Security Rule: If validation fails, the transaction reverts immediately. Validation code is strictly restricted (no state access outside the wallet, no timestamp lookups) to prevent bundler denial-of-service (DoS) attacks.

Phase 2: Execution (executeUserOp)

Once all operations in the bundle are validated, the EntryPoint executes the transaction payload by calling the execution function on each Smart Account.

  • The Smart Account executes the target contract calls.
  • The EntryPoint calculates the exact gas consumed and charges either the Smart Account's deposit or the sponsoring Paymaster.
  • The remainder of the gas is refunded.

4. Live From Production: How Socio3 Actually Uses ERC-4337

Everything above isn't theoretical for us. Socio3 V2 is a production social media platform running on ERC-4337 right now. Here's the real Account Abstraction layer from our codebase — with the actual EntryPoint address, the Pimlico integration, and the developer rules we wrote after breaking things:

And these are the actual developer rules we enforce on every pull request. Rule 3 and Rule 4 exist because we shipped bugs that broke gasless tipping:

Was this lesson helpful?

Let us know what you think of this specification. (submitting anonymously)