# estimateFeesPerGas

> Overview of the estimateFeesPerGas function

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

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

Defined in: [packages/aa-infra/src/estimateFeesPerGas.ts:50](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/aa-infra/src/estimateFeesPerGas.ts#L50)

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.

## Example

```ts
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 Parameters

<table>
  <thead>
    <tr>
      <th align="left">Type Parameter</th>
      <th align="left">Default type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `TTransport` *extends* [`Transport`](https://viem.sh)
      </td>

      <td>
        [`Transport`](https://viem.sh)
      </td>
    </tr>

    <tr>
      <td>
        `TChain` *extends* `undefined` | [`Chain`](https://viem.sh)
      </td>

      <td>
        `undefined` | [`Chain`](https://viem.sh)
      </td>
    </tr>

    <tr>
      <td>
        `TAccount` *extends*
        | `undefined`
        | [`SmartAccount`](https://viem.sh)
        | [`Account`](https://viem.sh)
      </td>

      <td>
        | `undefined`
        | [`SmartAccount`](https://viem.sh)
        | [`Account`](https://viem.sh)
      </td>
    </tr>

  </tbody>
</table>

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `bundlerClient`
      </td>

      <td>
        \{ `account?`: [`SmartAccount`](https://viem.sh); `bundlerClient`: [`Client`](https://viem.sh)\<`TTransport`, `TChain`, `TAccount`>; `userOperation?`: [`UserOperationRequest`](https://viem.sh); }
      </td>

      <td>
        Bundler client with the rundler RPC method.
      </td>
    </tr>

    <tr>
      <td>
        `bundlerClient.account?`
      </td>

      <td>
        [`SmartAccount`](https://viem.sh)
      </td>

      <td>
        ‐
      </td>
    </tr>

    <tr>
      <td>
        `bundlerClient.bundlerClient`
      </td>

      <td>
        [`Client`](https://viem.sh)\<`TTransport`, `TChain`, `TAccount`>
      </td>

      <td>
        ‐
      </td>
    </tr>

    <tr>
      <td>
        `bundlerClient.userOperation?`
      </td>

      <td>
        [`UserOperationRequest`](https://viem.sh)
      </td>

      <td>
        ‐
      </td>
    </tr>

  </tbody>
</table>

## Returns

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

Estimated fee values.