eth_gasPrice - Base
Example code for the eth_gasPrice JSON-RPC method. Complete guide on how to use eth_gasPrice JSON-RPC in GetBlock Web3 documentation.
Parameters
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": "getblock.io"
}'const axios = require('axios');
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_gasPrice',
params: [],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const gasPriceWei = parseInt(response.data.result, 16);
const gasPriceGwei = gasPriceWei / 1e9;
console.log('Gas Price:', gasPriceGwei, 'gwei');Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x5f5e100"
}Response Parameters
Parameter
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?