Skip to main content

Gas

The RPC API enables you to query the gas price for a specific block or hash.


Quick Reference

ParameterTypeDescription
block_heightnumberSpecific block height to query gas price for
block_hashstringSpecific block hash to query gas price for
nullnullReturns gas price for the latest block

Gas Price

Description

Returns gas price for a specific block_height or block_hash.

  • Using [null] will return the most recent block's gas price.

  • method: gas_price

  • params: [block_height], ["block_hash"], or [null]

Example

null example:

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": [null]
}

block_height example:

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": [187310138]
}

block_hash example:

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": ["6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"]
}
Example response:
{
"jsonrpc": "2.0",
"id": "dontcare",
"result": {
"gas_price": "100000000"
}
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.