# eth\_feeHistory

Returns a collection of historical gas information from which you can decide what to submit as your `maxFeePerGas` and/or `maxPriorityFeePerGas`. This method was introduced with [EIP 1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md).

## **Parameters**

* `BLOCKCOUNT` - Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.
* `NEWESTBLOCK` - Highest number block of the requested range.
* `REWARDPERCENTILES` - (optional) A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used.

## Returns

`Object`

* `OLDESTBLOCK` - Lowest number block of the returned range.
* `BASEFEEPERGAS` - An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
* `GASUSEDRATIO` - An array of block gas used ratios. These are calculated as the ratio of `gasUsed` and `gasLimit`.
* `REWARD` - (Optional) An array of effective priority fees per gas data points from a single block. All zeroes are returned if the block is empty.

## Example

*NOTE:* In this example we are using public Ethereum endpoint. Ideally, for your own projects, you should use your own endpoint, which you can generate for free by connecting to your wallet [here](https://www.noderpc.xyz/).

{% tabs %}
{% tab title="ethers" %}

### Query

*NOTE:* `ethers` used below is a well-known web3 library, check it out [here](https://github.com/ethers-io/ethers.js/).

```javascript
import { ethers } from 'ethers';

const provider =
  new ethers
    .providers
    .JsonRpcProvider("https://www.noderpc.xyz/rpc-mainnet/public")

const info = async ()=> {
  const result = await provider.send("eth_feeHistory", ["0x5", "latest", []]);
  console.log(result);
}
info();
```

### Result

```json
{
    "oldestBlock": "0x1095f68",
    "baseFeePerGas": [
        "0x6267c40fd",
        "0x5eeb137c9",
        "0x61579f4dc",
        "0x617b7ecd7",
        "0x5e7bf9f3f",
        "0x6063cc764"
    ],
    "gasUsedRatio": [
        0.3582569,
        0.6021514,
        0.5057582,
        0.37697796666666666,
        0.5806718666666667
    ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.noderpc.xyz/node-rpc/ethereum-api-endpoints/eth_feehistory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
