To further increase Web3 adoption, we need innovative ways to improve decentralized applications’ subpar user experience (UX). Fortunately, this is where account abstraction enters the equation, which may be the key to obtaining the next one billion users into Web3. But what exactly is account abstraction, and how does it work in terms of implementation? Well, there are several proposals declaring how to implement account abstraction, but the Ethereum community currently favors the ERC-4337 standard, which originated from EIP-4337. If you want to learn more about this, follow along in this article as we explore the intricacies of ERC-4337, how it works, and why it’s needed!
Today’s article will explore ERC-4337 – an Ethereum standard that outlines the implementation of account abstraction. As such, to understand what ERC-4337 entails, we’ll start by exploring the concept of account abstraction and why it’s needed. From there, we’ll jump straight into ERC-4337 to explore the standard. In doing so, we’re going to explain how it works, explore this standard’s benefits, and cover some of its most prominent use cases. Next, we’ll briefly examine additional Ethereum Improvement Proposals (EIPs) to give you a more nuanced view of account abstraction. Lastly, to top things off, we’ll explore the Moralis Wallet API, which fully supports account abstraction and ERC-4337!
If you have ambitions to build Web3 projects, you must check out some additional tools Moralis offers beyond the Wallet API. Moralis provides a comprehensive suite of industry-leading APIs, allowing you to build Web3 projects faster and more efficiently. For instance, check out the Price API and explore the fastest way to get prices of crypto!
If this sounds intriguing, then you should also know you can sign up with Moralis entirely for free. Doing so gives you immediate access to all our APIs so you can start to leverage the full power of blockchain technology today!
Nevertheless, let’s jump straight into the article and explore the concept of account abstraction!
Account Abstraction – Why is ERC-4337 Needed?
ERC-4337, or Ethereum Request for Comment 4337, is a standard outlining the implementation of account abstraction. Consequently, to understand ERC-4337, we initially need to explore the concept of account abstraction and why it’s needed!
The Ethereum blockchain network has two central types of accounts: externally owned accounts (EOAs) and contract accounts. EOAs are controlled by users; meanwhile, contract accounts are managed by smart contract code. Both account types are essential for the Ethereum ecosystem. However, EOAs are required to interact with the network, as they are the only way for you to initiate transactions and execute smart contracts.
The problem with EOAs is their limitation to basic operations. And this restricts your options for interacting with the Ethereum blockchain. For instance, these limitations make it challenging to make batch transactions, require you to always pay gas in the chain’s native token, etc.
Fortunately, one of the solutions to the problems above is account abstraction!
But what is account abstraction? Account abstraction improves the flexibility in the management and behavior of EOAs, making it easier to create so-called smart contract wallets. A smart contract wallet is a special-purpose contract defining and managing user accounts. These wallets open up many opportunities, such as the ability to make batch transactions, outline flexible security rules, recover accounts without seed phrases, and much more.
All in all, account abstraction improves the support for smart contract wallets and shifts Web3 from the current approach of simple EAOs to a more flexible future where users can tailor accounts to their needs through smart contracts!
What is ERC-4337?
Account abstraction on the Ethereum network can take several shapes and forms. And multiple EIPs outline various approaches for streamlining the implementation of this concept. However, as mentioned earlier, the community currently favors ERC-4337.
That said, what is ERC-4337?
ERC-4337 is an Ethereum standard, and it was initially deployed to the mainnet in March 2023. The ERC-4337 standard proposes an implementation of account abstraction using an alternative mempool and provides smart contracts with EOA features. Furthermore, ERC-4337 is a way to combine smart contract functionality and wallets in a single account, enabling the seamless creation of so-called smart contract wallets. This significantly improves the flexibility of Ethereum accounts, making it easier to implement services like multi-factor authentication, automatic payments, etc.
An important aspect of ERC-4337 is that it doesn’t require any alternations to the Ethereum core protocol, and this is one of the many reasons why the community currently favors this approach.
Now, with a brief overview, let’s look at how the ERC-4337 standard works in further detail!
How Does ERC-4337 Work?
So, how does ERC-4337 work? To answer this question, let’s explore the critical components of ERC-4337:
UserOperations: The higher-level system of ERC-4337 is built using an object type called
UserOperationsare pseudo-transaction objects that represent operations to be conducted on users’ behalf. Furthermore,
UserOperationsare broadcasted into the alternative mempool, where bundlers can gather multiple transactions into a single operation.
- Bundlers: Bundlers are responsible for keeping an eye on the alternative mempool built for
UserOperations. The bundlers are tasked with ”bundling”
UserOperationsinto one transaction and submitting it to the
EntryPointis a smart contract receiving the operations from the bundlers. And it’s responsible for unpacking, verifying, and executing
- Paymaster: ERC-4337 also introduces a paymaster mechanism responsible for handling the implementation of gas payment policies. The gas payment policies provide increased flexibility in who pays the gas and how. For instance, it can remove the requirement for the user to pay gas fees in the chain’s native token.
- Aggregator: Aggregator is a helper smart contract that interacts with the smart contract account, helping it validate signatures from several
Ultimately, the ERC-4337 standard introduces multiple new components to the Ethereum network, each with an important role in enabling account abstraction and smart contract wallets!
What are the Benefits of ERC-4337?
Now, to better understand ERC-4337, let’s take a closer look at some of the main benefits of this standard:
- Increased Security: We manage conventional Ethereum accounts using seed phrases and private keys. This can be problematic if a user loses their seed phrase or accidentally leaks their private key. With account abstraction and ERC-4337, you’re given more opportunities to implement additional options for both account recovery and authentication.
- Flexibility: Another central benefit of ERC-4337 is increased flexibility in how assets are managed on the Ethereum network. This is beneficial for both individuals and institutions. For example, account abstraction allows for the creation of more complex financial instruments like smart derivatives.
- Improved User-Experience (UX): The ERC-4337 standard and the increased flexibility give you, as a developer, the ability to build decentralized applications (dapps) that offer more intuitive, simple, and reliable experiences for the end-users. Consequently, it opens the door for dapps to become more like traditional applications, where users don’t need to worry about gas fees, key management, and other issues.
ERC-4337 Use Cases
With a better understanding of the benefits of ERC-4337, let’s take a closer look at some prominent real-world use cases:
- Multi-Operations: Interacting with smart contracts sometimes involves multiple steps and requires several transactions. However, through
UserOperations, ERC-4337 introduces a new way for developers and users to define a series of steps that will be executed in one single operation. This enables things such as batch transactions, allowing you and your users to avoid potentially costly and unnecessarily complex processes.
- Account Sharing: ERC-4337 lets you share various levels of access to your wallets with multiple users. Consequently, you can, for instance, choose to share your account with a user over a given time period and limit how much they can spend.
- Two-Factor Authentication: With the increased flexibility of account abstraction, you can implement additional security features such as two-factor authentication.
- Gas Cost Flexibility: The ERC-4337 standard and account abstraction allow for sponsored transactions where one user can pay another user’s gas fees. This allows for more flexibility when it comes to transaction fee handling.
- Automate Transactions: With conventional EOAs, you must manually initiate and sign transactions yourself. However, ERC-4337 and smart contract accounts allow you to define parameters to automate transactions. This opens up the door for monthly recurring transactions, such as payments for a subscription service.
EIP-4337 – short for Ethereum Improvement Proposal 4337 – is the proposal behind ERC-4337. It’s an initial proposal for a technical change to the Ethereum network, and EIP-4337 was initially introduced in 2021 by Vitalik Buterin and other prominent developers. EIP-4337 later turned into ERC-4337 when it got approved through Ethereum’s on-chain governance model in March 2023.
Beyond EIP-4337 – Exploring Other Account Abstraction EIPs
While the community prefers EIP-4337, there are other EIPs also outlining various approaches for account abstraction. Therefore, we’ll take this section to dive a bit deeper into these proposals, starting with EIP-2771!
- EIP-2771: EIP-2771 introduces so-called “meta-transactions” that allow third-party actors to pay for another user’s gas costs. The idea is that transactions are sent to a ”Forwarder” contract. The ”Forwarder” contract is then responsible for verifying the transaction and passing it along to a gas relay. The gas relay then sends the transaction to a ”Recipient” contract that pays the fee, making the transaction executable. What’s more, EIP-2771 doesn’t require any changes to the Ethereum protocol.
- EIP-2938: Unlike EIP-4337 and EIP-2771, EIP-2938 proposes to update the Ethereum protocol by introducing a new transaction type called
AA_TX_TYPE. Introducing this transaction type will give Ethereum native support for smart contract wallets.
- EIP-3074: EIP-3074 proposes to update EOAs of the Ethereum network, giving them the ability to delegate control to smart contracts. Updating EOAs in this way would allow smart contracts to approve transactions from user accounts. However, for this to work, it would require two new EVM
opcodesto be added:
All in all, at the moment, the community currently favors EIP-4337 and ERC-4337 as the best solution for account abstraction. A large contributing factor to this is that EIP-4337 didn’t demand any updates or changes to the Ethereum protocol!
The Moralis Wallet API – Full ERC-4337 Compatability
Do you want to build your own Web3 wallet? Or, perhaps you want to implement wallet functionality into your dapps? If so, then you’ll want to check out the Moralis Wallet API!
The Wallet API supports over 500 million addresses across multiple blockchain networks, including Ethereum, Polygon, BNB Smart Chain, Arbitrum, and many others. Furthermore, the Wallet API boasts a comprehensive array of powerful features, unparalleled scalability, and exceptional flexibility.
With only single lines of code, you can effortlessly fetch the native balance of an address, get all NFTs in a wallet, get all transactions of a wallet, check wallet activity, and much more. Consequently, when working with Moralis and the Wallet API, it has never been easier to build Web3 wallets or implement wallet functionality into your dapps!
What’s more, this interface features full support for account abstraction, making it the ultimate ERC-4337 Wallet API. As such, with this tool, you can now seamlessly get the native balance, NFT balance, transaction history, wallet activity, and much more from any smart contract wallet in a heartbeat.
So, if you’d like to build a Web3 wallet or implement wallet functionality into your dapps, make sure to check out the industry’s leading Wallet API!
Summary: What is ERC-4337 and EIP-4337?
In today’s article, we dove into the ins and outs of ERC-4337, which is a standard that originated from EIP-4337. In doing so, we learned that it’s an Ethereum standard outlining the implementation of account abstraction. We also explained how it works, covered the benefits of the standard, and explored some of its most prominent use cases!
Additionally, we introduced you to the Moralis Wallet API, as it fully supports the ERC-4337 standard, making it the ultimate tool for account abstraction and smart contract wallets. Consequently, if you’re looking to build a Web3 wallet or want to implement wallet functionality into your projects, check out the Wallet API immediately.
Furthermore, did you know that we offer multiple other Web3 APIs allowing you to build dapps faster and more efficiently? For example, check out the Web3 Market Data API or explore the industry’s best free NFT API!
If you liked this tutorial, then we highly recommend that you check out some more content here on the Web3 blog. For instance, read our ultimate guide to NFT marketplace development or learn how to use the getLogs method. Also, before you click away, remember to sign up with Moralis. You can set up our account entirely for free, and you’ll gain immediate access to the industry’s leading APIs!