0%
Overview page background
HomeOverviewsAccount Abstraction
What is a bundler? (ERC-4337)

What is a bundler? (ERC-4337)

Brady Werkheiser headshot

Written by Brady Werkheiser

Logan Ross headshot

Reviewed by Logan Ross

Published on February 5, 20244 min read

Account Abstraction (AA) is a standard that describes the use of higher-level infrastructure to enable smart contract accounts to become the primary type of account for users without requiring protocol-level changes to Ethereum.

Bundlers are a core piece of infrastructure that effectuates the use of smart contract accounts in place of Externally Owned Accounts (EOAs), which are the current default type of account used by Ethereum wallets.

Add embedded wallets to your web3 app using Embedded Accounts and our vertically integrated account abstraction infrastructure stack that includes a high performance Bundler and Gas Manager (ERC-4337 paymaster).

A bundler is a special node that monitors an alternative mempool of user operations, and bundles user ops from multiple senders into a single transaction so they can be executed on a blockchain. 

Because smart contract accounts can not initiate transactions on blockchains that don’t support account abstraction natively, they need to send a pseudo-transaction object called a user operation. A user operation is an ABI-encoded struct that “describes a transaction to be sent on behalf of a user.” 

To execute the transaction defined inside of a user operation, bundlers use their own Externally Owned Account (EOA) to initiate the transactions on behalf of the senders. Because bundlers initiate the transactions on behalf of senders, they cover the gas fees upfront, and are then repaid by the sender, or a paymaster if the transaction is sponsored.

As defined by the ERC-4337 proposal, bundlers are a “specialized class of actors” that can be run by “either block builders running special-purpose code, or users that can relay transactions to block builders.” More broadly, a bundler can be any node that bundles packages of multiple user operations and sends them to the singleton entry point contract.

Bundlers monitor an alternative mempool of user operations that are waiting to be bundled into a single transaction. Bundlers then package user ops from the alt mempool, and then send the bundle to the entry point contract for validation and execution by calling the handleOps() function on the entry point contract.

Bundlers use their Externally Owned Account to initiate transactions on behalf of senders, and are responsible for initially paying for the gas required to execute the transactions. 

After the entry point validates and executes the bundle of user ops, the bundler is repaid from the sender’s wallet, or by a paymaster contract if the user operation is being sponsored.

How user operations are validated and executed

In this example from our deep dive on the AA, the “bundler” is called an “Executor” with an Externally Owned Account, and shows how multiple senders request the bundler to send their user operations to the entry point contract. 

Once the entry point smart contract receives the user ops, the contract uses the validateOp and executeOp functions on the sender’s smart contract wallets to validate and execute the user operations on behalf of the senders.

An ERC-4337 bundler pays the transaction fee to send a bundle to the entry point contract. The entry point will calculate the gas used by each user operation, multiply that by the calculated fee, and compensate the bundler for this value after the user operation completes. 

Additionally, bundlers may charge for requests sent through their bundler API endpoints and they may charge a percentage of the gas fees if the transaction was sponsored by a paymaster policy.

If developers use the alchemy_requestGasAndPaymasterAndData and eth_sendUserOperation to construct and send a sponsored user operation to Alchemy’s AA infrastructure APIs, it will cost approximately $0.001575 plus 8% of the gas fees covered by the sponsorship policy. 

The $0.001575 cost is the sum of two bundler API endpoints being called: 

  • alchemy_requestGasAndPaymasterAndData (1,250 CUs) - to estimate and fill in the user op parameters 

  • eth_sendUserOperation (1,000 CUs) - to send the user op to Alchemy’s bundler

At a rate of $0.70 per 1M CUs (compute units), 2,250 CUs costs $0.001575 per user op.

Note: This is a single example, and there may be other Bundler API or Gas Manager Coverage API methods that are used to construct and send the user operation, which will impact the total compute unit costs. More information about the compute unit costs of Bundler API methods and the Bundler API fee logic can be found in our documentation.

In addition to the Bundler CU costs, Alchemy’s Gas Manager charges an 8% fee of the gas fees that were paid to sponsor a user operation, fronting the gas fees, and initiating the transaction on behalf of the sender. 

For example, if the sponsoring paymaster policy covered a transaction that cost $3.00 USD, the Gas Manager would charge an additional $0.24 to make the total cost of executing the sponsored transaction $3.24 USD.

Account abstraction and the usability benefits they afford through smart contract wallets, are simplifying how users interact with the blockchain and decentralized applications.

Here are a few educational ERC-4337 resources to support your learning journey:

  1. Learn how to refactor your dapp to work with smart contract wallets

  2. Set up a paymaster sponsorship policy with Alchemy’s Gas Manager API

  3. Read our bundler quickstart guide to begin sending user ops

If you’re interested in contributing to open-source Account Abstraction projects, explore EIP-6900, which details a standard interface for creating modular smart contract accounts and account plugins, and contribute to Alchemy’s open-sourced AA Software Development Kit (SDK).

You can also read more in Alchemy's Bundler API docs.

Overview cards background graphic
Desktop section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key