Optimism
Optimism
Optimism
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_getBlockByNumber returns the full block object for an OP Mainnet block at a given height or named tag such as latest, safe, or finalized. It is the primary way to walk this OP Stack rollup — which produces a block roughly every 2 seconds and prices gas in ETH — for indexing and monitoring. Send the request to https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa), choosing whether to include full transaction objects or just their hashes.
latest block for a real-time dashboard tracking the sequencer's ~2s cadence.finalized block to anchor queries that must survive a reorg before L1 settlement.includeTransactions=false) before fetching receipts in bulk via eth_getBlockReceipts.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | blockTag | string | Sí | The block to retrieve. |
| 2 | includeTransactions | boolean | Sí | When true, transactions[] contains full transaction objects. When false, only hashes. |
| Tipo | Descripción |
|---|---|
| object | null | Same block object as eth_getBlockByHash. Returns null if the block does not exist. |
Try it live in the Optimism playground.
| Código | Mensaje | Causa |
|---|---|---|
-32602 | Invalid params | Block number is malformed or block tag is unrecognised. |
includeTransactions, not the string "true" — JSON-RPC rejects the string form.eth_getBlockReceipts once instead of issuing N separate eth_getTransactionReceipt requests.includeTransactions=true, a heavily loaded OP Mainnet block can return a 1–2 MB response; size your buffers and timeouts accordingly.Parámetros
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"
true = full tx objects, false = tx hashes only