Skip to content
Alchemy Logo

estimateFeesPerGas

function estimateFeesPerGas<TTransport, TChain, TAccount>(
  bundlerClient,
): Promise<{
  maxFeePerGas: bigint;
  maxPriorityFeePerGas: bigint;
}>;

Defined in: packages/aa-infra/src/estimateFeesPerGas.ts:50

A custom estimateFeesPerGas function for viem bundler clients to use rundler_getUserOperationGasPrice for fee estimation.

It fetches gas price via rundler_getUserOperationGasPrice and returns the suggested.maxFeePerGas and suggested.maxPriorityFeePerGas values directly.

import { createBundlerClient } from "viem/account-abstraction";
import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
 
const bundler = createBundlerClient({
  transport: http("<rundler-url>"),
  userOperation: {
    estimateFeesPerGas: alchemyEstimateFeesPerGas,
  },
});

Type ParameterDefault type

TTransport extends Transport

Transport

TChain extends undefined | Chain

undefined | Chain

TAccount extends | undefined | SmartAccount | Account

| undefined | SmartAccount | Account

ParameterTypeDescription

bundlerClient

{ account?: SmartAccount; bundlerClient: Client<TTransport, TChain, TAccount>; userOperation?: UserOperationRequest; }

Bundler client with the rundler RPC method.

bundlerClient.account?

SmartAccount

bundlerClient.bundlerClient

Client<TTransport, TChain, TAccount>

bundlerClient.userOperation?

UserOperationRequest

Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; }>

Estimated fee values.

Was this page helpful?