A quick overview of the standard for developers.
This page gives a simplified overview of ERC-4337 so that developers can get a basic understanding of the different components and how they can be pieced together to build their applications.
Need to see the nitty-gritty details?
We recommend going straight to the source.
There are four main components to ERC-4337: a UserOperation, Bundler, EntryPoint, and Contract Account. These can be supplemented by Paymasters and Aggregators.
- UserOperations are pseudo-transaction objects that are used to execute transactions with contract accounts. These are created by your app.
- Bundlers are actors that package UserOperations from a mempool and send them to the EntryPoint contract on the blockchain.
- EntryPoint is a singleton smart contract that handles the verification and execution logic for transactions.
- Contract Accounts are smart contract accounts owned by a user.
- Paymasters are optional smart contract accounts that can sponsor transactions for Contract Accounts.
- Aggregators are optional smart contracts that can validate signatures for multiple Contract Accounts.
All Stackup tools are ERC-4337 compliant and composable with other open-source packages
All components of ERC-4337 revolve around a pseudo-transaction object called a UserOperation which is used to execute actions through a smart contract account. It captures the intent of what the user wants to do. This isn't to be mistaken for a regular transaction type.
|The address of the smart contract account.|
|Code used to deploy the account if not yet on-chain.|
|Data that's passed to the |
|Gas limit for the execution phase.|
|Gas limit for the verification phase.|
|Gas to compensate the bundler for the overhead to submit a UserOperation.|
|Similar to EIP-1559 max fee.|
|Similar to EIP-1559 priority fee.|
|Paymaster contract address and any extra data the paymaster contract needs for verification and execution. When set to |
|Used to validate a UserOperation during verification.|
You will see reference to two phases of ERC-4337: verification and execution. Verification is checking the validity of UserOperations, and execution is the actual execution of those transactions.
A Bundler is a class of actors that sends UserOperations to the EntryPoint. Specifically, it:
- Listens to at least one UserOperation mempool.
- Runs simulations.
- Bundles an array of UserOperations.
- Relays bundles to the EntryPoint.
Mempools for UserOperations are separate from the regular blockchain transaction mempool.
A public peer-to-peer UserOperation mempool is still a work in progress and expected to go live in summer 2023. However, ERC-4337 can still be used today with private mempools.
The EntryPoint is a singleton contract that acts as a central entity for all ERC-4337 accounts and paymasters. It coordinates the verification and execution of a UserOperation. For this reason, it's important for all implementations of an EntryPoint to be audited and immutable.
The above sequence diagram shows how the EntryPoint handles a batch of UserOperations sent by the Bundler. Essentially there are two phases:
- Verification loop: Verifies that each UserOperation is valid by checking it with both the Contract Account and the Paymaster contract.
- Execution loop: Sends the
callDatain each UserOperation to the Contract Account.
The verification loop will also make sure that either the Contract Account or Paymaster contract can pay the maximum gas cost for each UserOperation.
Bundlers only check the verification phase
Bundlers only check that the verification of each UserOperation will pass, not that the transaction will execute.
The Contract Account is an end user's account. At minimum it needs to check whether or not it will accept a UserOperation during the verification loop.
Additional features to support other account functions like social recovery and multi-operations can be added here too.
The Paymaster is an entity that is able to sponsor the gas fees of a UserOperation. It is required to do two things:
- Check whether or not it will accept a UserOperation during the verification loop.
- Run any required fee logic in the execution loop.
An example of Paymaster logic could be to withdraw a certain amount of ERC-20 tokens from the Contract Account after the UserOperation is executed. This allows users to pay for gas in any currency they choose.
The Aggregator is an entity that is trusted by Contract Accounts to validate signatures. They are often used to aggregate signatures from multiple UserOperations together.
Here's a single figure that summarizes how ERC-4337 works:
Updated about 1 month ago
Dig deeper into ERC-4337 or jump straight into the Getting Started guide.