• Core
  • Actions
  • fetchFeeData

fetchFeeData

Action for fetching network fee information.

import { fetchFeeData } from '@wagmi/core'

Usage

import { fetchFeeData } from '@wagmi/core'
 
const feeData = await fetchFeeData()

Return Value

{
  gasPrice: BigNumber
  maxFeePerGas: BigNumber
  maxPriorityFeePerGas: BigNumber
  formatted: {
    gasPrice: string
    maxFeePerGas: string
    maxPriorityFeePerGas: string
  }
}

Configuration

chainId (optional)

Force a specific chain id for the request. The wagmi Client's ethers provider must be set up as a chain-aware function for this to work correctly.

import { fetchFeeData } from '@wagmi/core'
 
const feeData = await fetchFeeData({
  chainId: 1,
})

formatUnits (optional)

Formats fee data using ethers units. Defaults to wei.

import { fetchFeeData } from '@wagmi/core'
 
const feeData = await fetchFeeData({
  formatUnits: 'gwei',
})