2.1 KiB
2.1 KiB
title, description
| title | description |
|---|---|
| useGasPrice | Hook for fetching the current price of gas (in wei). |
useGasPrice
Hook for fetching the current price of gas (in wei).
Import
import { useGasPrice } from 'wagmi'
Usage
::: code-group
import { useGasPrice } from 'wagmi'
function App() {
const result = useGasPrice()
}
<<< @/snippets/react/config.ts[config.ts] :::
Parameters
import { type UseGasPriceParameters } from 'wagmi'
chainId
config['chains'][number]['id'] | undefined
ID of chain to use when fetching data.
::: code-group
import { useGasPrice } from 'wagmi'
import { mainnet } from 'wagmi/chains' // [!code focus]
function App() {
const result = useGasPrice({
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 { useGasPrice } from 'wagmi'
import { config } from './config' // [!code focus]
function App() {
const result = useGasPrice({
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 { useGasPrice } from 'wagmi'
import { config } from './config' // [!code focus]
function App() {
const result = useGasPrice({
scopeKey: 'foo', // [!code focus]
})
}
<<< @/snippets/react/config.ts[config.ts] :::
Return Type
import { type UseGasPriceReturnType } from 'wagmi'