Documentation Index
Fetch the complete documentation index at: https://docs.near.org/llms.txt
Use this file to discover all available pages before exploring further.
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.
- method:
gas_price
- params:
[block_height], ["block_hash"], or [null]
null (latest)
by block height
by block hash
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": [null]
}
import { JsonRpcProvider } from "near-api-js";
const provider = new JsonRpcProvider({
url: "https://test.rpc.fastnear.com",
});
const response = await provider.gasPrice(null);
http POST https://rpc.testnet.near.org \
jsonrpc=2.0 \
id=dontcare \
method=gas_price \
params:='[null]'
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": [187310138]
}
import { JsonRpcProvider } from "near-api-js";
const provider = new JsonRpcProvider({
url: "https://archival-rpc.testnet.near.org",
});
const response = await provider.gasPrice(187310138);
http POST https://archival-rpc.testnet.near.org \
jsonrpc=2.0 \
id=dontcare \
method=gas_price \
params:='[187310138]'
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "gas_price",
"params": ["6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"]
}
import { JsonRpcProvider } from "near-api-js";
const provider = new JsonRpcProvider({
url: "https://archival-rpc.testnet.near.org",
});
const response = await provider.gasPrice(
'6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w',
);
http POST https://archival-rpc.testnet.near.org \
jsonrpc=2.0 \
id=dontcare \
method=gas_price \
params:='["6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"]'
{
"jsonrpc": "2.0",
"id": "dontcare",
"result": {
"gas_price": "100000000"
}
}