Skip to content
On this page

getGasPrice

Returns the current price of gas (in wei).

Usage

ts
import { publicClient } from './client'

const gasPrice = await publicClient.getGasPrice() 
ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})

Returns

bigint

The gas price (in wei).

JSON-RPC Method

eth_gasPrice

Released under the MIT License.