ERC 4337
What is ERC-4337?
ERC-4337 is an Ethereum standard that implements account abstraction without requiring changes to the core Ethereum protocol. Instead of relying on traditional Externally Owned Accounts (EOAs) controlled by private keys, users can operate through smart contract wallets with enhanced flexibility, security, and usability.
Why is ERC-4337 Important?
Traditionally, Ethereum has two types of accounts:
Externally Owned Accounts (EOAs):
Controlled by private keys (e.g., MetaMask, Ledger).
Only EOAs can sign transactions.
If the private key is lost, funds are permanently inaccessible.
Smart Contract Accounts:
Can include custom logic (multi-signature, social recovery, spending limits).
Require an EOA to initiate transactions, limiting usability.
ERC-4337 removes the dependency on EOAs, allowing transactions to be validated directly by smart contracts, enabling features like: - Multi-Factor Authentication - Gas fee payment in any ERC-20 token - Social recovery and key rotation - Transaction batching
ERC-4337 Architecture Overview
Key Components of ERC-4337
ERC-4337 introduces a new mempool and several key actors:
User Operation (
UserOp
) – A new transaction format sent to the network.Smart Contract Wallet – A contract that verifies and executes transactions instead of a private key signing it.
Bundler – A specialized node that collects multiple UserOps and submits them as a single Ethereum transaction.
EntryPoint Contract – A singleton contract that ensures security and execution of transactions.
Paymaster – Allows gas fee abstraction (users can pay gas in stablecoins or get sponsorships).
ERC-4337 Architecture Diagram
ERC-4337 Code Structure
1. Smart Contract Wallet (Minimal Implementation)
The smart contract wallet must be able to validate transactions without relying on EOAs. Below is a basic implementation of an ERC-4337-compatible wallet:
Key Features:
- The wallet can validate User Operations (UserOps) via validateUserOp()
.
- Allows execution of transactions without an EOA using executeTransaction()
.
- Owner-based control using OpenZeppelin’s Ownable
.
Key Features: - Ensures only authorized wallets can send UserOps. - Acts as a universal validation layer. - Bundlers interact with this contract to process transactions.
Key Features:
- Aggregates multiple UserOps into one transaction to reduce fees.
- Sends transactions via the EntryPoint
contract.
Key Features: - Allows gas sponsorship (dApps can cover user gas fees). - Users can pay fees in USDT, DAI, or any ERC-20 token.
Advantages
Improved UX: No need to manage private keys directly.
Gas Fee Flexibility: Pay gas in any ERC-20 token.
Multi-Factor Authentication (MFA): Enhanced security.
Social Recovery: No risk of losing funds due to lost private keys.
Transaction Batching: Execute multiple transactions at once.
Disadvantages
Higher Gas Costs: Smart contract wallets consume more gas than EOAs.
Increased Complexity: Requires new infrastructure (bundlers, paymasters).
Adoption Hurdles: dApps and wallets must integrate ERC-4337 support.
Last updated
Was this helpful?