Polygon
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Polygon
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_feeHistory returns historical base fees, gas-used ratios, and priority-fee percentiles for a window of recent Polygon PoS blocks. Polygon implements EIP-1559, so fees are paid in MATIC as a base fee plus a priority tip, and this method gives you the raw data to estimate both. Because Polygon produces a block roughly every 2 seconds, a window of even a few hundred blocks still only spans minutes — ideal for a responsive fee oracle. Query https://polygon.therpc.io/YOUR_API_KEY (chain ID 137, 0x89) with a block count, a newest block, and the percentiles you want sampled.
maxFeePerGas and maxPriorityFeePerGas from recent percentile data for type-2 Polygon transactions.gasUsedRatio climb toward 1.reward values to land in competitive blocks.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | blockCount | string | number | Sí | Number of blocks to include in the history window. Most providers cap this at 1024. |
| 2 | newestBlock | string | Sí | The most recent block to include in the window.Predeterminado: 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. |
| Tipo | Descripción |
|---|---|
| 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 |
Try it live in the Polygon playground.
| Código | Mensaje | Causa |
|---|---|---|
-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. |
baseFeePerGas array has one more element than the block window: the last entry is the node's prediction for the next Polygon block, not a confirmed value.blockCount produces a big response; most providers cap it at 1024, and capping yourself at 100–200 blocks per call keeps payloads small and oracle updates fast.Parámetros
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.