Skip to content

estimateMaxPriorityFeePerGas

Returns an estimate for the max priority fee per gas (in wei) for a transaction to be likely included in the next block.

If chain.fees.defaultPriorityFee is set on the Client Chain or override Chain, it will use that value.

Otherwise, the Action will either call eth_maxPriorityFeePerGas (if supported) or manually calculate the max priority fee per gas based on the current block base fee per gas + gas price.

Usage

example.ts
import { publicClient } from './client'
 
const maxPriorityFeePerGas = await publicClient.estimateMaxPriorityFeePerGas()
Output: 1_000_000_000n

Returns

bigint

An estimate (in wei) for the max priority fee per gas.

Parameters

chain (optional)

Optional Chain override. Used to infer the default maxPriorityFeePerGas from chain.fees.defaultPriorityFee.

import { optimism } from 'viem/chains'
 
const maxPriorityFeePerGas = 
  await publicClient.estimateMaxPriorityFeePerGas({
    chain: optimism 
  })