The RPC API enables you to query the gas price for a specific block or hash.
Quick Reference
| Parameter | Type | Description |
|---|
block_height | number | Specific block height to query gas price for |
block_hash | string | Specific block hash to query gas price for |
null | null | Returns gas price for the latest block |
Gas Price
Returns gas price for a specific block_height or block_hash.
Using [null] will return the most recent block’s gas price.
[block_height], ["block_hash"], or [null]
Query latest gas price
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": [null]
}
Query by block height
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": [187310138]
}
Query by block hash
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": ["6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"]
}
{
"jsonrpc": "2.0",
"id": "dontcare",
"result": {
"gas_price": "100000000"
}
}
For error handling information, see the RPC Errors documentation.