For the complete documentation index, see llms.txt. This page is also available as Markdown.

eth_gasPrice - Scroll

Example code for the eth_gasPrice JSON-RPC method. Complete guide on how to use eth_gasPrice JSON-RPC in GetBlock Web3 documentation.

This method returns the current legacy gas price in wei, as a hex-encoded integer. On GIWA Sepolia it reflects the L2 execution gas price and is used for legacy (non-EIP-1559) transactions.

Parameters

This method does not require any parameters. Send the request with an empty params array.

Request

curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_gasPrice",
    "params": [],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_gasPrice',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_gasPrice',
        'params': [],
        'id': 'getblock.io'
    }
)

print(response.json())

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0xf4240"
}

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

string

Hex-encoded gas price in wei

Use Cases

  • Legacy Pricing: Set gasPrice on type-0 transactions for tooling that predates EIP-1559

  • Fee Estimates: Show an approximate execution fee before a user signs

  • Cost Monitoring: Track L2 execution gas price over time

  • Batch Planning: Decide when execution costs are low enough to submit queued work

Error Handling

Error Code
Message
Description

-32603

Internal error

The node failed to compute the gas price

-32601

Method not found

The eth module is disabled on the client build

Web3 Integration

Last updated

Was this helpful?