Skip to main content

ERC-4337 Overview

What is ERC-4337

ERC-4337 is a higher-layer infrastructure for Ethereum to allow account abstraction. This will allows user to use a smart contract account to handle all network interactions. ERC-4337 introduces a new transaction called a UserOperation. Users will send signed UserOperations to a network of nodes called a Bundlers. Bundlers, will send these transactions to Entrypoint smart contract to execute the UserOperations. ERC-4337 also introduces paymaster smart contracts to allow transaction sponsorship. With paymaster users have gasless transactions or pay gas fees with ERC-20 tokens.

UserOperation Type

Users create a UserOperation for actions they want their account to perform.

FieldTypeDescription
senderaddressThe account making the operation
nonceuint256Anti-replay parameter; also used as the salt for first-time account creation
initCodebytesThe initCode of the account (needed if and only if the account is not yet on-chain and needs to be created)
callDatabytesThe data to pass to the sender during the main execution call
callGasLimituint256The amount of gas to allocate the main execution call
verificationGasLimituint256The amount of gas to allocate for the verification step
preVerificationGasuint256The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata
maxFeePerGasuint256Maximum fee per gas (similar to EIP-1559 max_fee_per_gas)
paymasterAndDatabytesAddress of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction)
signaturebytesData passed into the account along with the nonce during the verification step

How does ERC-4337 work

AA high level

There are five main components to ERC-4337: a UserOperation, Bundler, EntryPoint Contract, Wallet(Account), and Paymaster Contract.

  1. Wallet(Account)
    • Wallet contract - a contract representing a user smart contract account
    • Wallet Deployer - a contract(singleton) that creates a wallet contract
    • Wallet software - UX client app used to sign and send the UserOperation to the Bundler node.
  2. UserOperation - Users create a UserOperation for actions they want their account to perform. Users will send signed UserOperations to a network of nodes called a Bundlers.
    • Like a transaction, it contains sender, to, calldata, maxFeePerGas, maxPriorityFee, signature, and nonce.
    • Unlike a transaction, it contains several other fields.
  3. EntryPoint - A smart contract that executes bundles of UserOperations as a standard transaction.
  4. Bundler - A Bundler is a special type of node that works alongside Ethereum execution clients. It acts as a relayer, processing UserOperations. It performs simulations to ensure that the UserOperations are valid. Enforces storage access rules and opcode banning. Checks things like verifying signatures and handling gas fees. It then take valid UserOperations and package them together into a bundled transaction. Bundlers, will send this bundled transactions to Entrypoint smart contract for execution. It is important to note that not all block-builders on the network need to be bundlers. If a Bundler doesn't want to be a block-builder, it can use an API like Flashbots. Flashbots will allow the transaction to bypass the transaction mempool.
  5. Paymaster - This contract can pay for transactions instead of the wallet itself. Wallet contracts can choose Paymaster to sponsor or pay transactions themselves.