Ask or search…
⌃K
Links

eth_gasPrice

How to use it

TypeScript/JavaScript
1
// yarn add @tatumio/tatum
2
​
3
import { TatumSDK, AvalancheC, Network } from '@tatumio/tatum'
4
​
5
const tatum = await TatumSDK.init<AvalancheC>({network: Network.AVALANCHE_C})
6
​
7
const gasPrice = await tatum.rpc.gasPrice()
8
​
9
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The eth_gasPrice method is an JSON-RPC method used to estimate the average gas price required for transactions in the network. This method provides a suggestion for the gas price to be used in a transaction to increase the likelihood of it being mined and included in a block in a reasonable amount of time. The eth_gasPrice method is particularly useful for developers and users who want to create and send transactions, as it helps them estimate the appropriate gas price to ensure timely processing.

Parameters

The eth_gasPrice method does not require any parameters.

Return Value

The eth_gasPrice method returns a single value as a hexadecimal string:
  • gasPrice: The estimated average gas price in wei. Example: "0x4a817c800"

JSON-RPC Request and Response Examples

Request

{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": []
}

Response

{
"id": 1,
"jsonrpc": "2.0",
"result": "0x4a817c800"
}
By using the eth_gasPrice method, developers and users can estimate the appropriate gas price for their transactions, improving the overall user experience and ensuring that their transactions are processed in a timely manner.
© Tatum Technology, LLC