> For the complete documentation index, see [llms.txt](https://docs.noderpc.xyz/node-rpc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.noderpc.xyz/node-rpc/ethereum-api-endpoints/eth_feehistory.md).

# 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 %}
