---
eip: 4337
label: ERC-4337
title: Account Abstraction Using Alt Mempool
status: Final
type: Standards Track
category: ERC
created: 2021-09-29
requires: 712, 7702
official: https://eips.ethereum.org/EIPS/eip-4337
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-4337.md
canonical: https://eips.huatuo.xyz/eip-4337/
lang: en
tldr: Account abstraction without changing the protocol - smart-contract wallets send UserOperations through a separate mempool, bundlers put them on-chain via the EntryPoint contract, and paymasters can sponsor gas.
tags: [account-abstraction, smart-wallet, bundler, paymaster, gasless]
---

# ERC-4337: Account Abstraction Using Alt Mempool

> Account abstraction without consensus-layer protocol changes, instead relying on higher-layer infrastructure.

**TL;DR:** Account abstraction without changing the protocol - smart-contract wallets send UserOperations through a separate mempool, bundlers put them on-chain via the EntryPoint contract, and paymasters can sponsor gas.

## What problem does it solve?

Ordinary Ethereum accounts (EOAs) are rigid: one secp256k1 private key, no recovery if you lose it, no spending limits, one call per transaction, and you must hold ETH to pay gas. Smart-contract wallets can do all of that, but a contract cannot start a transaction on its own; someone with an EOA has to trigger it and pay.

Earlier proposals wanted to fix this inside the protocol, which requires a hard fork and consensus. ERC-4337 achieves "account abstraction" purely with contracts and off-chain infrastructure, so it works on any EVM chain today.

## How it works

1. **UserOperation**. Instead of a transaction, the user signs a `UserOperation` object: `sender` (the smart account), `nonce`, `callData`, gas limits, fee fields, an optional `paymaster` and a `signature` of any format.
2. **Alt mempool & Bundlers**. UserOperations go to a dedicated mempool. *Bundlers* pick them up, simulate them, bundle several into one normal transaction and call `EntryPoint.handleOps(...)`, paying the gas.
3. **EntryPoint**. A single audited singleton contract. For each op it calls `validateUserOp` on the sender account (which checks the signature and pays the EntryPoint for gas), then executes `callData`, then reimburses the bundler.
4. **Paymaster** (optional). A contract that agrees to pay gas for the op: sponsoring onboarding, accepting ERC-20 tokens instead of ETH, etc.
5. **Factory** (optional). If the account does not exist yet, `initCode` / `factory` deploys it in the same operation, so a user's first action can be from a counterfactual address.

The result: wallets with passkeys, multisig, social recovery, session keys, batched calls and gasless onboarding, with no protocol change.

## Sample code

The interface every ERC-4337 account implements (v0.7):

```solidity
struct PackedUserOperation {
    address sender;
    uint256 nonce;
    bytes   initCode;            // factory address ++ factoryData, or empty
    bytes   callData;
    bytes32 accountGasLimits;    // verificationGasLimit (16 bytes) ++ callGasLimit (16 bytes)
    uint256 preVerificationGas;
    bytes32 gasFees;             // maxPriorityFeePerGas (16 bytes) ++ maxFeePerGas (16 bytes)
    bytes   paymasterAndData;    // paymaster ++ gas limits ++ paymasterData, or empty
    bytes   signature;
}

interface IAccount {
    /// Return 0 if the signature is valid, 1 (SIG_VALIDATION_FAILED) otherwise.
    /// Must transfer `missingAccountFunds` to the EntryPoint when non-zero.
    function validateUserOp(
        PackedUserOperation calldata userOp,
        bytes32 userOpHash,
        uint256 missingAccountFunds
    ) external returns (uint256 validationData);
}
```

A deliberately minimal account owned by one EOA key:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

contract SimpleAccount is IAccount {
    address public immutable entryPoint;
    address public owner;

    constructor(address _entryPoint, address _owner) { entryPoint = _entryPoint; owner = _owner; }

    function validateUserOp(PackedUserOperation calldata op, bytes32 opHash, uint256 missing)
        external returns (uint256)
    {
        require(msg.sender == entryPoint, "only EntryPoint");
        address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(opHash), op.signature);
        if (missing != 0) payable(entryPoint).call{value: missing}("");
        return signer == owner ? 0 : 1;
    }

    function execute(address to, uint256 value, bytes calldata data) external {
        require(msg.sender == entryPoint, "only EntryPoint");
        (bool ok, bytes memory ret) = to.call{value: value}(data);
        require(ok, string(ret));
    }
}
```

Sending an operation from a client (viem's account-abstraction module):

```ts
import { createBundlerClient } from "viem/account-abstraction";
import { http } from "viem";
import { sepolia } from "viem/chains";

const bundler = createBundlerClient({
  account,                       // a SmartAccount object (e.g. toCoinbaseSmartAccount / toSimpleSmartAccount)
  chain: sepolia,
  transport: http("https://your-bundler.example/rpc"),
});

const hash = await bundler.sendUserOperation({
  calls: [{ to: "0x...", value: 0n, data: "0x..." }],
  // paymaster: true,            // let a paymaster sponsor the gas
});
const receipt = await bundler.waitForUserOperationReceipt({ hash });
```

Under the hood this calls the bundler's JSON-RPC method `eth_sendUserOperation(userOp, entryPoint)`.

## Things to know

- The EntryPoint is a shared contract with a fixed address per version (v0.6 `0x5FF1…2789`, v0.7 `0x0000000071727De22E5E9d8BAf0edAc6f37da032`). Accounts and bundlers must agree on the version.
- Validation code is restricted: no banned opcodes like `TIMESTAMP` in ways that let simulation diverge from execution, and limited storage access (see [ERC-7562](/eip-7562/)). This is what keeps the mempool spam-resistant.
- You need a bundler service (Alchemy, Pimlico, Biconomy, Candide, self-hosted…) and typically a paymaster service; they are infrastructure, not part of the chain.
- [EIP-7702](/eip-7702/) lets an existing EOA behave like a smart account; ERC-4337 supports 7702 accounts natively, so the two are complementary rather than competing.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-4337
