FeeHistory
What Eth.feeHistory returns: the base fees, the gas usage and
the priority fees of a range of blocks, one array per figure.
import { Effect } from "effect";import { Eth } from "@ethect/core/rpc";
const busiest = Effect.gen(function* () { const history = yield* Eth.feeHistory(10, "latest", []); // history: FeeHistory.FeeHistory const ratio = Math.max(...history.gasUsedRatio); return history.oldestBlock + BigInt(history.gasUsedRatio.indexOf(ratio));});The arrays are aligned: the entry at index i is about the block oldestBlock + i.
Schemas
Section titled “Schemas”| Schema | Type | Describes | Returned by |
|---|---|---|---|
FeeHistory.schema |
FeeHistory.FeeHistory |
fees over a range of blocks | Eth.feeHistory |
Fields
Section titled “Fields”| Field | Type | Notes |
|---|---|---|
oldestBlock |
bigint |
the number of the first block of the range |
baseFeePerGas |
ReadonlyArray<bigint> |
in wei, one per block, plus one for the block after the range |
gasUsedRatio |
ReadonlyArray<number> |
gas used over gas limit, between 0 and 1, one per block |
reward |
ReadonlyArray<ReadonlyArray<bigint>> (optional) |
in wei, per block, the priority fee at each percentile asked for |
baseFeePerBlobGas |
ReadonlyArray<bigint> (optional) |
in wei, one per block, plus one for the block after the range, since Cancun |
blobGasUsedRatio |
ReadonlyArray<number> (optional) |
blob gas used over the limit, one per block, since Cancun |
Behavior
Section titled “Behavior”- One more base fee than blocks. For a range of
nblocks,baseFeePerGasandbaseFeePerBlobGashaven + 1entries and the other arrays haven. The last base fee is that of the next block. rewardfollows the percentiles.reward[i][j]is the priority fee at thej-th percentile asked for, in blockoldestBlock + i. Asked for none, anvil answers with an empty array.- Ratios are
numbers. A ratio is a JSON number on the wire, not a hex quantity. Every fee is abigint. - Optional means absent.
rewardand the two blob fields are left out of the object when the node does not send them or sendsnull. Test withhistory.reward !== undefined. baseFeePerGasandgasUsedRatioare always arrays. A node asked about no block leaves them out or sendsnull: both read as[].