What is Account Abstraction (ERC-4337)?
Account Abstraction as defined by ERC-4337, "allows users to use smart contract wallets containing arbitrary verification logic instead of EOAs as their primary account." ERC-4337 introduces many user experience benefits, most notably enabling people to use Smart Contracts as their primary accounts.
ERC-4337 runs on top of the blockchain and does not require any changes to the blockchain itself. This makes it usable today, on Ethereum or any EVM chain, without any significant changes to the underlying blockchain infrastructure.
On March 1st, 2023, Yoav Weiss from the Ethereum Foundation, announced that ERC-4337 was live on Ethereum mainnet when the EntryPoint contract was first deployed. Integrating Account Abstraction is as simple as plugging in Alchemy's Account Kit.
What are the key concepts of Account Abstraction?
The key concepts of Account Abstraction are UserOperation, Bundler, Sender, EntryPoint, Paymaster, and Aggregator. In combination, these concepts work together to enable web3 developers to build smart contract wallets and make dapps compatible with SCWs.
A user operation is a “pseudo-transaction object” representing a user’s transaction intent. Any user operation can contain multiple instructions and additional data to execute smart contract calls initiated by the Smart Contract Account. UserOperations begin the 4337 transaction flow.
What is the difference between a UserOperation and traditional transaction?
Three key differences between a UserOperation and regular transaction are:
Additional fields - UserOperations include new fields in the transaction structure (e.g., EntryPoint, Bundler and Aggregator)
Alternate mempool - UserOperations are sent to a separate mempool, where bundlers can package them into transactions which get included in a block
Authentication - for a transaction, authentication is always done via a signature from a single private key that can never change for a given sender. In a user op, authentication is programmable.
A bundler monitors an alternative mempool specifically built for user operations. The bundler bundles multiple user operations into a single transaction and submits that transaction to the entry point contract. Bundlers are compensated for doing this by taking a portion of the gas fees.
Bundlers are a critical piece of infrastructure to actualize ERC-4337 because all Ethereum transactions need to be initiated by an Externally Owned Account (EOA). Bundlers have EOAs, and in an account abstracted ecosystem they are the only participants that need EOAs. One of the main goals of ERC-4337 is to abstract away the need for everyone in web3 to have their own EOA wallet.
The EntryPoint is a singleton smart contract that receives transactions from Bundlers, then verifies and executes UserOperations.
How does the EntryPoint verification process work?
The smart contract account gets to define its own verification and therefore its own authentication. During the verification process the EntryPoint contract checks to see if the wallet has enough funds to pay the maximum amount of gas it might possibly use, which is based on the gas fields in the UserOperation. If the wallet does not have enough funds, the EntryPoint contract rejects the transaction.
How does the EntryPoint execution process work?
During the execution process the EntryPoint contract executes the user operation by calling the account using the calldata specified in the user operation, and taking money from the Smart Contract Account to reimburse the Bundler with the right amount of ETH to pay for the gas.
The Paymaster is an ERC-4337 defined smart contract that handles the implementation of gas payment policies. These gas policies create flexibility for how gas is paid (e.g. in what currency) and by whom, which removes the prerequisite for users to hold native blockchain tokens to interact with the blockchain.
For example, the native blockchain token for Ethereum is ETH and the native blockchain token for Polygon is MATIC. Therefore, instead of paying gas for Ethereum transactions in the native token (e.g. ETH), users can pay for gas fees with any ERC20 token like USD Coin (USDC) or Tether (USDT).
Paymasters allow application developers to:
Sponsor gas fees for their users
Enable gas payments in stablecoins
Enable gas payments in other ERC-20 tokens
Alchemy’s Gas Manager API realizes the benefits of ERC-4337 defined Paymasters by completely abstracting away gas payments from users, while doing it in a robust way that lets the application decide what that abstraction should be (e.g. sponsored transactions, pay gas with stablecoins, etc).
An Aggregator is a smart contract that implements a signature scheme that supports aggregation (i.e. a contract that can verify aggregated signatures.
If multiple messages are signed with different keys, then a single combined signature can be generated that verifies the combined signature, and implies that all the constituent signatures are also valid.
By combining multiple signatures into a single signature, aggregators help save on calldata costs, with multiple bundled UserOperations validated in a single step.
How did EIP-2938 and EIP-3074 inform the design of ERC-4337?
ERC-4337 builds upon previous Ethereum Improvement Proposals (EIPs) 2938 and 3074. EIP-2938 introduced the idea for enabling smart contracts to operate as a "top-level account that pays fees and starts transaction execution," and EIP-3074 introduced the idea of delegating "control of the externally owned account (EOA) to a smart contract."
EIP-4337 used the ideas introduced by EIP-2938 and EIP-3074 and combined them with the idea for using an alternative mempool and an implementation route that did not require any change in the consensus layer.
Learn The Reasons Why Developers Are Adopting Account Abstraction Over Meta Transactions
Explore Meta Transactions, Covering Gas Fees and Understanding Why They’re No Longer the Ideal Solution.
Discover How Smart Contract Accounts Use Modules and Plugins to Create New Extensions