Bundler utilities

A collection of utility functions for interacting directly with a Bundler.

There may be certain cases where your application needs to interact with the Bundler directly and outside the context of an Account Instance. The Bundler namespace provides a collection of simple utility functions for doing so.

SendUserOperationWithEthClient

Uses an instance of a viem PublicClient or ethers.js JsonRpcProvider to directly call eth_sendUserOperation on a Bundler. It returns a Promise that resolves to a userOpHash hex string.

import { V06 } from "userop"

const userOpHash = await V06.Bundler.SendUserOperationWithEthClient(
  userOperation,
  entryPointAddress,
  bundlerClient, // either viem PublicClient or ethers.js JsonRpcProvider
);

GetUserOperationReceiptWithEthClient

Uses an instance of a viem PublicClient or ethers.js JsonRpcProvider to directly call eth_getUserOperationReceipt on a Bundler. It returns a Promise that resolves to a User Operation receipt object if it has been included on-chain or null if not.

import { V06 } from "userop"

const receipt = await V06.Bundler.GetUserOperationReceiptWithEthClient(
  userOpHash,
  bundlerClient, // either viem PublicClient or ethers.js JsonRpcProvider
);

If the User Operation has been included in a block, the returned receipt will have the following type:

interface UserOperationReceipt {
  userOpHash: Hash;
  sender: Address;
  paymaster: Address;
  nonce: Hex;
  success: boolean;
  actualGasCost: Hex;
  actualGasUsed: Hex;
  from: Address;
  receipt: TransactionReceipt;
  logs: Array<Log>;
}