7 min read
This guide is the first part of a two-part series focused on understanding and implementing the ERC-4337 Ethereum Improvement Proposal (EIP). In this part, we will explore the technical aspects of ERC-4337, digging deep into its key concepts, such as UserOperations, Bundlers, EntryPoint, and Contract Accounts. We aim to provide a comprehensive understanding of how ERC-4337 works and the problems it's trying to solve.
The second part of this series will be a practical tutorial where you'll learn to create and deploy a smart contract that complies with the ERC-4337 standard. We recommend going through this first part to fully grasp the underlying principles before moving on to the hands-on coding in the second part.
So, if you're ready to dive into the fascinating world of Ethereum standards, let's get started!
The rage surrounding Ethereum these days (Q2 2023) is about Account Abstraction. Why? Well, custodial wallets (e.g., Externally Owned Accounts (EOA)) are hard to manage, and the user experience can be difficult. There are Smart Contract wallets that exist today (e.g., Argent, Safe), but they aren't as interoperable as we'd like and still have to rely on EOA for submitting transactions. In this guide, we'll talk about ERC-4337, an Ethereum Improvement Proposal (EIP) that aims to solve the issues of difficult wallet user experience.
What You Will Need
What You Will Do
- Learn about ERC-4337
- Learn about the current state of ERC-4337, its past and future
Exploring Account Types in Ethereum: EOAs vs SCAs
Before we get into ERC-4337, let's quickly recap the types of accounts available on Ethereum today, their characteristics and features:
|Externally-Owned Account (EOA)
|Smart Contract Accounts (SCA)
|Directly owned by a private key holder
|Owned and controlled by the code deployed within the smart contract itself
|Controlled by a private key; therefore, direct interaction is possible only by the owner of the key
|Controlled by the business logic defined in the smart contract code. Any user can interact with it, as defined by the contract
|Created when a private/public key pair is generated, often by an Ethereum wallet
|Created when a smart contract is deployed or when a smart contract is executed and the smart contract creates it
|Non-updatable. The private-public key cannot be changed once set
|Depending on the contract code, it may be updatable (e.g., upgrading the contract logic)
|Origin of Transactions
|Only EOAs can originate transactions. The EOA signs the transaction with its private key
|Cannot originate transactions. They execute operations in response to received messages (transactions or calls from other contracts)
|Can hold Ether balance
|Can hold Ether balance, and also the state of variables and functions
These two types of accounts have some similarities in that they are restricted to using Ethereum's only signing signature (which technically isn't bad but should be noted), Elliptic Curve Digital Signature Algorithm (ECDSA). Both account types are also limited in design flexibility that involves multiple transactions or complex interactions between accounts, especially if these operations involve different types of accounts. Both accounts also must pay gas fees in the native token of the blockchain (e.g., Ether).
Now let's talk about ERC-4337, which helps solve some of these limitations.
What is Account Abstraction / ERC-4337?
ERC-4337, also known as Account Abstraction Using Alt Mempool, is a draft EIP that aims to solve the challenges discussed above. However, ERC-4337 isn't the first EIP to try and solve these challenges. It was first brought to attention in 2016 with EIP-86 (Abstraction of transaction origin and signature), then later again in 2020 with EIP-2938 and EIP-3074. Safe to say, developers have been trying to solve this issue since the early days of Ethereum but were unsuccessful because most of these EIPs required core changes to the Ethereum protocol.
Account Abstraction, aka ERC-4337, is a new approach to solving the wallet user experience on Ethereum today. Account Abstraction acts as a "smart contracts wallet" where users can engage with the Ethereum network without possessing their own private keys or having to maintain Ether for transaction costs. It uses an alternative mempool (aka Alt Mempool) design to accept and interpret messages (which we'll get into later) to facilitate these transactions.
Account Abstraction opens up the doors to:
- Multi-Operations: Certain interactions with smart contracts involve multiple steps and require multiple transactions. For example, when interacting with a DeFi protocol, a user might need to approve a token transfer, then deposit that token, and then perform some other action. Each step needs to be initiated separately by an EOA, which is a cumbersome and potentially costly process. ERC-4337 proposes to solve this issue by introducing a new transaction type called "UserOperation." UserOperations allow users to define a series of steps that should be executed as part of a single operation. These steps are then executed by the EntryPoint contract, which acts as a proxy for the user. Don't worry about UserOperation and EntryPoint yet, we'll get into it soon.
- Multi-Signature: ERC-4337 allows for multi-sig like functionality, opening up the door to different use-cases like social recovery (e.g., account recovery via your trusted peers), governance security (e.g., unauthorized transactions), and more.
- Custom Signature Schemes: The ability for alternative signature schemes. Ethereum today uses ECDSA for transaction signatures, and although it is secure and widely used, additional signature schemes open up the door to different use cases, potentially improving interoperability and user experience.
- Gas costs flexibility: ERC-4337 enables "sponsored transactions" where someone else can pay for the gas fee, allowing more flexibility in transaction fee handling.
- Upgradability: The ERC-4337 standard uses a proxy contract, making it possible to be "upgradeable". This can allow for new features and bug fixes without interrupting the interoperability within the ecosystem.
Now that we have a high-level understanding of ERC-4337, let's dive into the nitty-gritty details.
Analysis of ERC-4337's Key Components
Now let's take a deeper look into the key components of ERC-4337:
- UserOperations - Think of UserOperations as a "to-do list" that you provide to your Ethereum account. This "to-do list" can include things like transferring funds, interacting with a smart contract, or even a combination of multiple actions. In the current Ethereum model, you need to manually do each item on this list, one transaction at a time, but with UserOperations in ERC-4337, you can bundle these actions together into one single operation, sign it, and then let the Ethereum network handle the rest. UserOperations has a similar transaction field structure to the current Ethereum transactions being used today but includes some logic updates pertaining to ERC-4337.
- Bundlers - Now, after creating your UserOperation, you need someone to take this and put it into the Ethereum network for you. This is where Bundlers come in. Bundlers can be thought of as facilitators. They are validators or MEV (Maximal Extractable Value) searchers who take your UserOperation, bundle it with others, and submit them all together to the Ethereum network.
- EntryPoint - The EntryPoint is a smart contract that acts like a gatekeeper for the Ethereum network. Once the Bundlers submit the UserOperations, the EntryPoint is responsible for unpacking the bundle and executing all the operations. If it encounters any operation that fails, it can roll back (or undo) all the actions of that operation, ensuring the integrity and reliability of the transactions.
- Contract Account - A Contract Account is like your automated assistant on the Ethereum network. Unlike the regular accounts (EOAs) that need to manually initiate every action, Contract Accounts can automatically perform actions based on the instructions they receive (such as those from a UserOperation). They can interact with other contracts, hold and manage assets, and even make decisions based on their programmed logic. This makes them a powerful tool for automating and simplifying complex transactions on Ethereum.
- Paymaster - This is an optional entity (i.e., smart contract) that can pay (sponsor) transaction fees on behalf of your transaction. It agrees to reimburse the Bundler (i.e., the entity that submits the transaction to the network) for the gas costs. The specifics of when and how the Paymaster pays the fees can be defined in the smart contract.
- Aggregators - This is an optional smart contract that interacts with the Contract Account, helping it validate signatures from multiple UserOperations together.
In summary, the ERC-4337 standard introduces several new components to the Ethereum architecture, each with a significant role in the transaction process.
- Understanding ERC-4337 and ERC-4804 Standards
- Vitalik Buterin Blog Post
- Ethereum Improvement Proposal: EIP-4337
- Ethereum Magicians: ERC-4337 Account Abstraction
Throughout this guide, we delved into the world of Account Abstraction, specifically focusing on ERC-4337, an Ethereum Improvement Proposal (EIP) aimed at enhancing the wallet user experience. We learned about the types of Ethereum accounts currently in use, the challenges they face, and how ERC-4337 plans to solve these problems. Keep an eye out for Part-2 of this Account Abstraction and ERC-4337 series, where we will show you how to create and deploy an ERC-4337 compliant smart contract.
We would love to hear more about what you are building and how you plan to use ERC-4337 for your project. Drop us a line in Discord, or give us a follow on Twitter to stay up to date on all the latest information!
We ❤️ Feedback!
Let us know if you have any feedback or requests for new topics. We'd love to hear from you.