Skip to content

estimateUserOperationGas

Calls eth_estimateUserOperationGas and returns the result

Usage

ts
import { client } from "./client";

const estimates = await client.estimateUserOperationGas(
  {
    // ... user operation
  },
  "0xEntryPointAddress"
);
ts
import { createBundlerClient, mainnet } from "@alchemy/aa-core";
import { http } from "viem";

export const client = createBundlerClient({
  chain: mainnet,
  transport: http("https://eth-mainnet.g.alchemy.com/v2/demo"),
});

Returns

Promise<UserOperationEstimateGasResponse<EntryPointVersion>

The result of the estimate including the callGasLimit, verificationGasLimit, preVerificationGas, and additionally, paymasterVerificationGasLimit for EntryPointVersion v0.7.0 user operations.

Parameters

request: UserOperationRequest<EntryPointVersion>

The user operation to send

entryPoint: Address

The address of the entry point to send the user operation to