One of the primary obstacles preventing the next billion users from entering Web3 is the industry’s subpar user experience (UX). The barriers to entry are high, and a significant hurdle for mass adoption has always been an unfamiliarity with gas fees. What’s more, networks like Ethereum have, from a conventional perspective, required users to pay for transactions using each chain’s native token, and acquiring them can be a daunting task for newcomers to the Web3 space. Fortunately, there’s a solution for removing this hurdle: meta transactions (ERC-2771). But what exactly are meta transactions? And how do they work? For the answers to these questions, accompany us in this article as we dive into the intricacies of meta transactions!
Overview
In today’s article, we’ll explore ERC-2771 – a standard outlining a protocol for smart contracts on Ethereum to support meta transactions natively. As such, to kick things off, we’ll start by diving into the intricacies of meta transactions. From there, we’ll jump into the ERC-2771 standard to explain how it works. We will then briefly discuss the advantages and disadvantages of meta transactions. Lastly, we’ll compare ERC-2771 to ERC-4337 account abstraction, the standard currently preferred by the Ethereum community!
We’ll also introduce you to the Moralis Wallet API, which is the ultimate tool for integrating wallet functionality into your decentralized applications (dapps). The reason for exploring this tool, in particular, is that it’s compatible with ERC-4337 account abstraction.
However, if you’re serious about building Web3 projects, consider exploring additional Moralis tools. A great example is the Price API, which allows you to seamlessly get the prices of crypto with a single line of code.
If you want access to Moralis’ industry-leading Web3 APIs, don’t forget to sign up with Moralis. You can create your account free of charge, and you’ll be able to use the full power of blockchain technology in a heartbeat!
What are Meta Transactions?
From a traditional perspective, you have always needed to pay for Ethereum transactions using the chain’s native ETH token. This has long been a significant hurdle for mass adoption, as it requires new users to purchase ETH to interact with the Ethereum ecosystem – a potentially daunting task for someone just entering the crypto space. Fortunately, it’s possible to tackle this issue with so-called meta transactions, which is a form of account abstraction!
But what exactly are meta transactions?
Meta transactions are a popular method allowing users to interact with a blockchain network without paying transaction fees. Instead, they provide a safe and secure method enabling third-party actors to step in and cover a user’s gas costs.
So, how does this work?
Put simply, a user signs a message – preferably EIP-712 compliant – off-chain with information about the transaction to be executed. The signed message is then passed on to a third-party actor responsible for paying the gas fee and turning the request into a valid transaction.
To better understand the inner mechanics of this process, let’s take a closer look at ERC-2771, a popular standard outlining a secure protocol for native meta transactions on the Ethereum network!
How Does Meta Transactions Work? ERC-2771 Explained
ERC-2771, short for ”Ethereum Request for Comment 2771”, is a standard outlining a secure contract-level protocol for smart contracts on Ethereum to accept meta transactions natively. A good thing about this new proposed standard is that it demands no changes or updates to the Ethereum blockchain itself.
So, how does the ERC-2771 standard work?
To answer the question above, let’s start by defining four core components of ERC-2771:
- Transaction Signer: Responsible for signing and sending transactions to a ”gas relay”.
- Gas Relay: Gets a signed request off-chain from the ”transaction signer”. The ”gas relay” is responsible for paying the gas fee, turning the request into a valid transaction, and passing it through a ”trusted forwarder”.
- Trusted Forwarder: A contract that’s trusted by the ”recipient” contract to verify nonces and signatures correctly before forwarding the request from the ”gas relay” to the ”recipient”.
- Recipient Contract: A smart contract that accepts meta transactions via a ”trusted forwarder”.
Here’s a simplified example flow of how it works:
In sum, the ERC-2771 standard specifies a protocol allowing a user (”transaction signer”) to sign a message off-chain. The message is then passed to a third party (”gas relay”) responsible for paying the gas fee and turning the request into a valid transaction. The third party then sends the transaction to a ”forwarder” that verifies it. Lastly, the transaction ends up at the ”recipient contract”, the Ethereum contract the original user intended to call without paying the gas fee.
Advantages of Meta Transactions (ERC-2771)
Now, with an overview of what meta transactions are and how they work, let’s explore three benefits of the ERC-2771 standard:
- Gasless Transactions: ERC-2771 enables gasless transactions, which is possible since meta transactions allow users to offload gas fees to third-party actors, enabling them to interact with the Ethereum network without having to pay anything themselves.
- Gas Payment Flexibility: Meta transactions also provide more freedom in how users can pay for transactions. This means that users don’t need to hold ETH to be able to interact with the Ethereum network.
- Improved User Experience (UX): Both gasless transactions and gas payment flexibility open up the opportunity to improve the UX of dapps and other Web3 projects. Consequently, the ERC-2771 standard provides tools for lowering potential barriers to entry and contributes positively to the overall adoption of Web3.
Disadvantages of Meta Transactions (ERC-2771)
As we have been looking at three benefits of ERC-2771, let’s also look at a couple of disadvantages of meta transactions:
- Backward Compatability: A major challenge of the protocol outlined in the ERC-2771 standard is that it requires smart contracts to be written so they support meta transactions. This is a manageable issue for new contracts. However, it would require updates to all existing contracts that also want to adopt meta transactions.
- Security: Another critical challenge of ERC-2771 is to ensure the security of the meta-transaction protocol. Each meta transaction contains a
msg.sender
parameter to determine who signed the transaction. However, a malicious ”forwarder” can forge this value and effectively send transactions from any address. Consequently, the ”recipient” contract must be careful when trusting forwarders. This is essential to prevent unauthorized use of meta transactions and prevent relay attacks.
Due to the challenges above, the Ethereum community currently favors another approach, which is account abstraction using the ERC-4337 standard!
What is ERC-4337? Account Abstraction Explained
ERC-4337 is an Ethereum standard outlining a proposal for the implementation of account abstraction. Consequently, to understand ERC-4337, we initially need to dive into the concept of account abstraction and explain why it’s needed.
The Ethereum blockchain features two main types of accounts: contract accounts and externally owned accounts (EOAs). Smart contract accounts are controlled by smart contract code; meanwhile, EOAs are managed by users. Moreover, EOAs are crucial for the Ethereum ecosystem, as they are required for initiating transactions and executing smart contracts.
However, the problem is that EOAs are restricted to basic operations, limiting how you can interact with the Ethereum blockchain. For instance, it makes it hard to make batch requests, requires you to pay gas fees in the chain’s native ETH token, etc.
Fortunately, this is where account abstraction and the ERC-4337 standard enter the equation! ERC-4337 account abstraction makes EOAs more dynamic, increasing the flexibility in how Ethereum accounts are managed and behave. In essence, account abstraction makes it easier to create smart contract wallets that open up the opportunity to make batch requests, outline flexible security rules, and much more!
So, how does this work?
How Does ERC-4337 Work?
The ERC-4337 standard specifies a protocol for account abstraction through an alternative mempool and provides smart contracts with EAO features. It essentially combines the functionality of wallets and smart contracts, facilitating the effortless creation of smart contract wallets.
To better understand how this works, let’s take a closer look at some of the core components of the ERC-4337 standard:
UserOperations
: The higher-level system outlined in ERC-4337 is structured around a new object type calledUserOperations
. These are pseudo-transactions that represent operations that will be executed on behalf of users. Furthermore,UserOperations
transactions are sent to a mempool where bundlers gather multiple requests into a single operation.
- Bundlers: Bundlers are responsible for ”bundling”
UserOperations
into a single transaction and sending it to anEntryPoint
smart contract.
EntryPoint
: TheEntryPoint
contract is responsible for unpacking, verifying, and executingUserOperations
.
- Paymaster: The ERC-4337 standard also introduces a paymaster mechanism, allowing for more flexibility in who pays for gas and how.
- Aggregator: An aggregator contract interacts with smart contract accounts, helping them validate signatures from multiple
UserOperations
at the same time.
For a more detailed breakdown of account abstraction and the components above, check out our complete ERC-4337 guide!
Meta Transactions (ERC-2771) vs. Account Abstraction (ERC-4337)
Both meta transactions and ERC-4337 account abstraction were introduced to improve the user experience of Ethereum. However, meta transactions have the sole purpose of providing more flexibility in who pays gas fees; meanwhile, ERC-4337 aims to abstract away more than just gas-related complexities.
Consequently, account abstraction does everything that meta transactions do and more. And this is one of the reasons why the Ethereum community generally prefers ERC-4337 over ERC-2771. What’s more, this is also why ERC-4337 account abstraction is currently replacing many of the ERC-2771 solutions that exist today.
However, to further highlight why the community favors ERC-4337, let’s take a closer look at some benefits of account abstraction compared to meta transactions!
Benefits of Account Abstraction Compared to Meta Transactions
In this section, we’ll look at three benefits of ERC-4337 account abstraction compared to meta transactions:
- No Smart Contract Changes Required: As previously mentioned, backward compatibility is one of the most significant drawbacks of meta transactions. This is because ERC-2771 requires updates to all existing contracts that want to implement meta transactions.
However, this is not the case for ERC-4337 account abstraction, as it builds on existing infrastructure. As a result, all existing smart contracts support account abstraction by default, making it stand out as a superior option compared to meta transactions.
- Higher Compatability: Relayers in the ERC-2771 implementation lack consistency. Each relayer can have its own format specific to a particular use case. As a result, smart contracts might have to be updated to become compatible with all different relayers. This is, fortunately, not an issue for ERC-4337 account abstraction.
- More Decentralization: As ERC-4337 account abstraction grows, so does the number of bundlers making their services available. This allows developers to increasingly decentralize their transaction flow. Moreover, it gives developers more opportunities, allowing them to abandon sub-par bundlers.
All in all, even though meta transactions are a nice concept, ERC-4337 account abstraction is currently favored over ERC-2771!
Your Gateway to Account Abstraction: Introducing the Moralis Wallet API
Are you looking to build your own Web3 wallet? Or do you want to add wallet functionality to your Web3 projects? If so, then you’ll definitely want to check out Moralis’ industry-leading Wallet API!
Our Wallet API boasts unparalleled scalability, a number of powerful features, and incredible flexibility. What’s more, the interface supports 500+ million wallet addresses across multiple blockchains, including Ethereum, BNB Smart Chain, Optimism, Arbitrum, Polygon, and many others.
When working with the Wallet API, you can fetch the native balance of any address, check wallet activity, get all NFTs in a wallet, and much more with only single lines of code. As such, with Moralis, adding Web3 wallet functionality to your blockchain projects has never been easier! Furthermore, the Wallet API features full support for ERC-4337 account abstraction. Consequently, with this tool, you can now effortlessly get the NFT balance, transaction history, native balance, and much more from all smart contract wallets in no time.
As such, if you want to implement wallet functionality into your projects or build your own Web3 wallet, make sure to check out this industry-leading interface today!
Summary: What are Meta Transactions (ERC-2771)?
In today’s article, we explored the ins and outs of meta transactions (ERC-2771). In doing so, we learned that meta transactions are a popular method that allows users to interact with a blockchain network without having to pay transaction fees themselves. Instead, meta transactions provide a secure way for a third-party actor to cover a user’s gas fees.
However, in addition to exploring meta transactions, we also learned that the ERC-2771 standard has its drawbacks. Also, the Ethereum community currently favors account abstraction in the form of ERC-4337 over ERC-2771. Consequently, many of the existing ERC-2771 solutions are currently being replaced by ERC-4337 account abstraction.
If you liked this ERC-2771 article, consider reading more content here on the Web3 blog. For instance, read about the top NFT API providers in the industry, learn about getLogs, or check out our Ethereum testnet guide!
Also, before you leave, remember to sign up with Moralis. You can create an account for free, and you’ll get immediate access to all the industry’s leading Web3 APIs!
Read More: moralis.io