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
ts
import { publicClient } from './client'
const maxPriorityFeePerGas =
await publicClient.estimateMaxPriorityFeePerGas()
// 1_000_000_000n
import { publicClient } from './client'
const maxPriorityFeePerGas =
await publicClient.estimateMaxPriorityFeePerGas()
// 1_000_000_000n
ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http()
})
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http()
})
Returns
bigint
An estimate (in wei) for the max priority fee per gas.
Parameters
chain (optional)
- Type: Chain
- Default:
client.chain
Optional Chain override. Used to infer the default maxPriorityFeePerGas
from chain.fees.defaultPriorityFee
.
ts
import { optimism } from 'viem/chains'
const maxPriorityFeePerGas =
await publicClient.estimateMaxPriorityFeePerGas({
chain: optimism
})
import { optimism } from 'viem/chains'
const maxPriorityFeePerGas =
await publicClient.estimateMaxPriorityFeePerGas({
chain: optimism
})