2.7 KiB
2.7 KiB
title, description
| title | description |
|---|---|
| useEstimateFeesPerGas | Hook for fetching an estimate for the fees per gas (in wei) for a transaction to be likely included in the next block. |
useEstimateFeesPerGas
Hook for fetching an estimate for the fees per gas (in wei) for a transaction to be likely included in the next block.
Import
import { useEstimateFeesPerGas } from 'wagmi'
Usage
::: code-group
import { useEstimateFeesPerGas } from 'wagmi'
function App() {
const result = useEstimateFeesPerGas()
}
<<< @/snippets/react/config.ts[config.ts] :::
Parameters
import { type UseEstimateFeesPerGas } from 'wagmi'
chainId
config['chains'][number]['id'] | undefined
ID of chain to use when fetching data.
::: code-group
import { useEstimateFeesPerGas } from 'wagmi'
import { mainnet } from 'wagmi/chains' // [!code focus]
function App() {
const result = useEstimateFeesPerGas({
chainId: mainnet.id, // [!code focus]
})
}
<<< @/snippets/react/config.ts[config.ts] :::
config
Config | undefined
Config to use instead of retrieving from the nearest WagmiProvider.
::: code-group
import { useEstimateFeesPerGas } from 'wagmi'
import { config } from './config' // [!code focus]
function App() {
const result = useEstimateFeesPerGas({
config, // [!code focus]
})
}
<<< @/snippets/react/config.ts[config.ts] :::
scopeKey
string | undefined
Scopes the cache to a given context. Hooks that have identical context will share the same cache.
::: code-group
import { useEstimateFeesPerGas } from 'wagmi'
function App() {
const result = useEstimateFeesPerGas({
scopeKey: 'foo', // [!code focus]
})
}
<<< @/snippets/react/config.ts[config.ts] :::
type
'legacy' | 'eip1559'
- Defaults to
'eip1559'
::: code-group
import { useEstimateFeesPerGas } from 'wagmi'
function App() {
const result = useEstimateFeesPerGas({
type: 'legacy', // [!code focus]
})
}
<<< @/snippets/react/config.ts[config.ts] :::
Return Type
import { type UseEstimateFeesPerGasReturnType } from 'wagmi'