Understanding ERC-4337

Vesper Finance
Vesper Finance
Published in
5 min readJan 26, 2024

--

What is ERC-4337 and why was it such an important upgrade?

Overview

Introduction

The ERC-4337 standard, introduced in 2023, marked a significant step forward for Ethereum, particularly in improving interactions with DeFi protocols. Known predominantly for Account Abstraction, ERC-4337 enables smart contracts to utilize features typically associated with Externally Owned Accounts (EOAs). This development essentially bridged the gap between the flexibility of EOAs and the power of smart contract wallets.

Originally when Ethereum was established, it operated on different models with two types of accounts: EOAs, controlled by users through their public and private keys, and contract accounts, governed by smart contract code. Each had its strengths and weaknesses, leading to the question — why not merge these functionalities? ERC-4337 addressed this by combining the best aspects of both account types, offering a more integrated and efficient approach to managing digital assets.

How Does ERC-4337 Work?

Account Abstraction, a key feature of the ERC-4337 standard, simplifies user interactions with Ethereum by bypassing the consensus-layer protocol. Instead, it introduces a new protocol layer and alters the basic transaction type. This change brings in a concept called UserOperation, a kind of pseudo-transaction. Users send these UserOperation objects to an alternative mempool. Then nodes, known as bundlers, gather these objects and bundle them into a single transaction by calling a specific contract. The bundled transactions are sent to a global smart contract called the “EntryPoint”. This bundled transaction is what eventually gets included in a block.

Account Abstraction Flow — Source: Cointelegraph

To process these transactions, a bundler starts by making a call to a function named “handleOps” on the EntryPoint contract. When this function receives the bundled transaction, it triggers another function called “validateUserOp” for each account involved. This step is essential for ensuring that each transaction within the bundle is properly validated and processed.

The role of the “validateUserOp” function is critical in the transaction process. It verifies the authenticity of the operation’s signature and checks if it matches the account. If everything is correct, it processes the gas payment. Following this, each smart contract wallet is required to implement a specific function to execute the operation sent by the EntryPoint contract. This makes the entire process more smooth, ensuring a more automatic and user-friendly experience by eliminating the reliance on key dependencies.

The Benefits of ERC-4337

Wallet Recovery

ERC-4337 facilitates easier and more versatile wallet recovery methods through account abstraction. Unlike traditional wallets where recovery relies heavily on remembering a seed phrase, ERC-4337 enables alternative methods, such as setting up a trusted contact or using multi-factor authentication.

Increased Security

With ERC-4337, security is increased through a more robust authentication process. By shifting certain security responsibilities from the user to the smart contract, it reduces the chances of user errors. It also enables the implementation of additional security layers such as multi-signature verification or automated algorithms.

Flexibility

ERC-4337 significantly extends the scope of wallet functionality, including features such as shared accounts and multi-user operations. This means better collaboration for the management of funds and transactions, particularly beneficial for users who require joint control over assets.

Compatibility

Designed to be fully compatible with the Ethereum Virtual Machine (EVM), ERC-4337 ensures easy integration with various Layer 2 chains and other EVM-compatible chains. This compatibility facilitates smooth interoperability and extends the reach of ERC-4337’s benefits across a broader range of applications.

What is a Paymaster Contract?

Paymaster contracts within the ERC-4337 standard, offer a practical solution for handling transaction fees and may be crucial for users who are not familiar with or capable of managing Ethereum gas fees. They function by taking on the responsibility of gas costs to enable a better experience for users.

When a user initiates a transaction, the Paymaster contract essentially steps in by covering the gas fees. This approach is particularly beneficial as it enables a wider range of users to participate in the ecosystem without the immediate need to understand or possess ETH for gas. The contract holds funds that are used specifically for this purpose and is programmed with criteria to determine which transactions it will cover. This could be based on factors like the user’s history, the type of transaction, or other predefined rules set by the protocol that deploys the Paymaster contract. This means a DeFi protocol could set up a system where initiating and executing transactions are covered by them instead of the user, most likely found on a Layer 2 network such as Optimism.

This introduction of Paymaster contracts represents a step towards a more accessible ecosystem. By abstracting away the complexities of gas fees, these contracts help reduce the technical barriers associated with Ethereum transactions. This is especially important in trying to create a more inclusive environment where users from various backgrounds can interact with DeFi applications without the upfront need for technical knowledge. This could even extend to creating more common web2 frontends that users are familiar with and integrating a more web3 backend, utilizing the flexibility of ERC-4337.

Smart Wallets

Smart Wallets are an interesting part of ERC-4337 as they step away from what you’d expect from typical wallets, offering a smarter, contract-based interface. This isn’t just about making things simpler, it’s about opening the door to DeFi for more people.

These Smart Wallets are not just about storing assets. They are equipped to perform complex tasks such as automated transactions based on predefined conditions and offer increased security features such as multi-signature verification. The user interfaces are also more intuitive compared to standard wallets.

The main advantage of Smart Wallets lies in their proactive functionality. They go beyond typical basic functionality, actively managing and executing operations, which is particularly helpful for users less familiar with the technicalities of navigating the landscape.

How Does the Alt Mempool Work?

In the more conventional system, users typically submit transactions to a public mempool, which houses pending transactions for EOAs. However, within ERC-4337, UserOperations are directed towards a specialized, higher-level mempool known as the “UserOperation mempool.”

In order to facilitate the bundling process, bundlers actively monitor the UserOperation mempool, where they group multiple UserOperations into a standard transaction. Before bundling, they carefully assess the legitimacy of these UserOperations by using the relevant EntryPoint methods. Once validated, the bundler then includes the UserOperation transaction in the next block they propose to the network. It's important to note that this transaction is not sent to the regular mempool as bundlers are either block builders themselves, or work with block builders.

Summary

To Summarize, ERC-4337 was introduced in 2023 as an innovative approach designed to simplify the entire DeFi experience for users of all levels. It has many benefits from ensuring more security for users on a personal and smart contract level, to providing a more intuitive interface for users.

The ERC-4337 standard uses account abstraction and an alternative mempool to accommodate UserOperation transactions, granting users greater flexibility in customizing their options. Looking ahead, it is highly likely that more DeFi protocols will adopt account abstraction to facilitate a smooth transition and simplify the onboarding process for users.

--

--