Skip to main content

Bundler

Bundler is a branded Address type representing an ERC-4337 bundler node. Bundlers aggregate user operations from the mempool and submit them to the EntryPoint contract for execution.

Quick Start

import { Bundler } from '@tevm/voltaire/primitives/Bundler';

// Create bundler address
const bundler = Bundler.from("0x742d35Cc6634C0532925a3b844Bc9e7595f251e3");

// Convert to hex
console.log(Bundler.toHex(bundler));
// "0x742d35cc6634c0532925a3b844bc9e7595f251e3"

// Compare addresses
const same = Bundler.equals(bundler, "0x742d35Cc...");

Type Definition

import type { AddressType } from '../Address/AddressType.js';
import type { brand } from '../../brand.js';

export type BundlerType = AddressType & { readonly [brand]: "Bundler" };

API Reference

from

Create Bundler from address input.
function from(
  value: number | bigint | string | Uint8Array | AddressType
): BundlerType

toHex

Convert Bundler to hex string.
function toHex(
  bundler: number | bigint | string | Uint8Array | AddressType
): string

equals

Check if two Bundler addresses are equal.
function equals(
  bundler1: number | bigint | string | Uint8Array | AddressType,
  bundler2: number | bigint | string | Uint8Array | AddressType
): boolean

Bundler Responsibilities

Bundlers perform critical functions in the ERC-4337 ecosystem:
  1. Mempool monitoring: Watch for new user operations
  2. Simulation: Validate operations will succeed
  3. Aggregation: Bundle multiple operations into transactions
  4. Submission: Submit bundles to the EntryPoint contract
  5. Gas optimization: Optimize bundle ordering for gas efficiency

Bundler RPC Methods

Standard bundler RPC methods for interacting with bundlers:
// Submit user operation
await bundler.request({
  method: "eth_sendUserOperation",
  params: [userOp, entryPointAddress],
});

// Estimate gas
const gasEstimate = await bundler.request({
  method: "eth_estimateUserOperationGas",
  params: [userOp, entryPointAddress],
});

// Get user operation by hash
const receipt = await bundler.request({
  method: "eth_getUserOperationByHash",
  params: [userOpHash],
});

// Get user operation receipt
const receipt = await bundler.request({
  method: "eth_getUserOperationReceipt",
  params: [userOpHash],
});

References