Optimism
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Optimism
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_feeHistory returns historical base fees, gas-used ratios, and priority-fee percentiles for a window of recent OP Mainnet blocks, all denominated in ETH wei. OP Mainnet implements EIP-1559, so this method is the foundation for building type-2 fee strategies on the rollup: sample recent percentile data and derive sensible maxFeePerGas and maxPriorityFeePerGas values. Call https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa) with a block count, a newest block, and the percentiles you want.
maxFeePerGas and maxPriorityFeePerGas from recent percentile data.gasUsedRatio across recent blocks — values near 1 mean the sequencer is filling blocks.reward percentiles to set a competitive priority fee.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 1 | blockCount | string | number | نعم | Number of blocks to include in the history window. Most providers cap this at 1024. |
| 2 | newestBlock | string | نعم | The most recent block to include in the window.الافتراضي: latest |
| 3 | rewardPercentiles | number[] | لا | Array of percentile values (0–100) at which to sample priority fees from each block. Pass an empty array to omit reward data. |
| النوع | الوصف |
|---|---|
| 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 Optimism playground.
| الكود | الرسالة | السبب |
|---|---|---|
-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 extra element: the last entry is the node's prediction for the next OP Mainnet block, not a confirmed value — don't treat it as historical.blockCount values produce large responses (most providers cap at 1024); cap at 100–200 blocks per call and paginate to keep payloads manageable.المعاملات
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.