ERC-4337 Overview
Introduction
The proposal suggests a different approach to achieve account abstraction in Ethereum. It intends to enable users to use smart contract wallets with arbitrary verification logic instead of externally owned accounts (EOAs) as their primary accounts, without the need for any Ethereum consensus changes. To obtain a complete understanding of the specification, it is suggested to refer to the original source.
Components of ERC-4337
ERC-4337 consists of four primary components, namely UserOperation, Bundler, EntryPoint, and Contract Account. Additionally, Paymasters and Aggregators can also be used to complement these components.
UserOperation
In the context of the ERC-4337 account abstraction proposal, user operations refer to the actions taken by users on their accounts. A structure that describes a transaction to be sent on behalf of a user. To avoid confusion, it is not named “transaction”.
- Like a transaction, it contains sender, to, calldata, max fee per gas, max priority fee, signature, nonce
- Unlike a transaction, it contains several other fields, described below
- Also, the nonce and signature fields usage is not defined by the protocol, but by each account implementation
Field | Type | Description |
sender | address | The account making the operation |
nonce | uint256 | Anti-replay parameter; also used as the salt for first-time account creation |
initCode | bytes | The initCode of the account (needed if and only if the account is not yet on-chain and needs to be created) |
callData | bytes | The data to pass to the sender during the main execution call |
callGasLimit | uint256 | The amount of gas to allocate the main execution call |
verificationGasLimit | uint256 | The amount of gas to allocate for the verification step |
preVerificationGas | uint256 | The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata |
maxFeePerGas | uint256 | Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) |
maxPriorityFeePerGas | uint256 | Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) |
paymasterAndData | bytes | Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction) |
signature | bytes | Data passed into the account along with the nonce during the verification step |
Overall, user operations in ERC-4337 provide a more user-friendly and extensible interface for interacting with decentralized applications on the Ethereum network.
Bundler
A node (block builder) that bundles multiple UserOperations and creates an EntryPoint.Handleops() transaction. Note that not all block-builders on the network are required to be bundlers.
EntryPoint
A singleton contract to execute bundles of useroperations. Bundlers/clients whitelist the supported entrypoint.
Contract Account
The account contract sends a user operation. In the context of the ERC-4337 account abstraction proposal, a Contract Account is a special type of account that is associated with a smart contract on the Ethereum network.
Unlike traditional externally-owned accounts, Contract Accounts are not controlled by individual users, but instead operate autonomously based on the rules and logic defined by the associated smart contract.
Contract Accounts are created and managed using proxy contracts, which act as intermediaries between the user and the smart contract, abstracting away the details of the contract's implementation and providing a more user-friendly and efficient interface for interacting with decentralized applications on the EVM compatible network.
Supplementary Components
Aggregator
A helper contract trusted by accounts to validate an aggregated signature. Bundlers/clients whitelist the supported aggregators.
Paymaster
The Paymaster is a contract that is designated to pay for gas fees on behalf of a user or a group of users. The purpose of the Paymaster is to simplify the transaction process and improve user experience by eliminating the need for users to hold and manage their own native tokens (like ETH) for transaction fees.
This can be particularly useful for dApps and other blockchain services that involve frequent and complex transactions, as it allows for a more streamlined and efficient transaction process.
How Components Work Together
Simulation Phase
Execution Phase
Benefits of Using ERC-4337
Erc-4337 brings a lot of advantages for users:
- Achieve the key goal of account abstraction
- Decentralization
- Try to support other use cases
- Whitelist
- Send batch transaction (similar goal to EIP-3074)
- Pay tx fees with EIP-20 tokens
- Recovery
- Locking
- Guardian-based security
Summary
In simple terms, with ERC-4337, anyone can start trading in NFTs, get crypto newsletter memberships, play web3 games easily, and create new smart account wallets. All without having to become a technical guru. Things are about to get much easier and more fun for the average user and more accessible for the crypto beginner. Check out W3Smart Wallet!