BNB Smart Chain
eth_feeHistory
eth_feeHistory looks backward across a window of recent BNB Smart Chain blocks and returns each block's base fee (paid in BNB), its gas-used ratio, and priority-fee samples at the percentiles you request. With BSC sealing a block roughly every three seconds under PoSA, even a few dozen blocks captures a fresh, fine-grained fee picture. Call https://bsc.therpc.io/YOUR_API_KEY at chain ID 56, and the data becomes the raw input for an EIP-1559 fee strategy that picks sensible maxFeePerGas and tip values.
Use cases
- Build a fee estimator that reads recent percentile rewards to set
maxFeePerGasandmaxPriorityFeePerGasfor a BNB transaction. - Render a fee-trend chart in a wallet or in a bscscan.com-style explorer view.
- Watch
gasUsedRatioclimb toward 1.0 to detect BSC congestion during busy PancakeSwap windows. - Drive MEV-aware bidding by inspecting how high the upper reward percentiles run block to block.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | blockCount | string | number | Yes | Number of blocks to include in the history window. Most providers cap this at 1024. |
| 2 | newestBlock | string | Yes | The most recent block to include in the window.Default: latest |
| 3 | rewardPercentiles | number[] | No | Array of percentile values (0–100) at which to sample priority fees from each block. Pass an empty array to omit reward data. |
Response
| Type | Description |
|---|---|
| object | Object with: `oldestBlock` (hex, starting block of the window), `baseFeePerGas` (array of hex wei — one per block plus the next predicted value), `gasUsedRatio` (array of floats 0–1 per block), `reward` (array of arrays — per-block percentile priority fees in hex wei; only present when `rewardPercen |
Example request
Try it live in the BNB Smart Chain playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | invalid argument | blockCount is 0, out of range, or rewardPercentiles contains values outside 0–100. |
-32000 | block not found | `newestBlock` references a block that does not exist on this node. |
Common pitfalls
- The
baseFeePerGasarray carries one extra trailing entry: the node's forecast for the next BSC block, which has not been sealed yet — do not mistake it for a confirmed fee. - Against a network or node that predates EIP-1559 support, the call errors out or omits the fee fields entirely; guard for that path.
- A large
blockCountreturns a hefty payload, so cap the window at roughly 100–200 blocks per request and page through longer ranges.
Supported networks
- Mainnet — Chain ID: 56
- Testnet — Chain ID: 97
See also
Parameters
Hex or decimal integer, e.g. "0xa" or 10
"latest" | "safe" | "finalized" | hex block number
Array of percentile values (0–100) at which to sample priority fees from each block. Pass an empty array to omit reward data.