Optimism
Optimism
Optimism
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_getBlockByHash returns the full block object for the OP Mainnet block identified by a given 32-byte hash — header fields, gas metrics, withdrawals, and either transaction hashes or full transaction objects. OP Mainnet is an OP Stack rollup that pays gas in ETH and produces blocks about every 2 seconds, so block hashes turn over quickly. Send the request to https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa); an unknown hash returns null.
blockHash from a transaction receipt.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 1 | blockHash | string (hex) | نعم | The hash of the block to retrieve. |
| 2 | includeTransactions | boolean | نعم | When true, transactions[] contains full transaction objects. When false, only hashes. |
| النوع | الوصف |
|---|---|
| object | null | Block object with fields: number, hash, parentHash, timestamp, miner, gasUsed, gasLimit, baseFeePerGas, transactions, uncles, withdrawals, stateRoot, receiptsRoot, transactionsRoot, logsBloom, extraData, size, difficulty, totalDifficulty, mixHash, nonce, sha3Uncles. Returns null if no block was foun |
Try it live in the Optimism playground.
| الكود | الرسالة | السبب |
|---|---|---|
-32602 | Invalid params | Block hash is malformed or not 32 bytes. |
includeTransactions, not the string "true" — JSON-RPC distinguishes the two and a string is rejected.includeTransactions=true, a busy OP Mainnet block can return well over 1 MB of transaction objects; stream or chunk the response if bandwidth is constrained.null, not an error — always null-check before reading fields like number or transactions.المعاملات
0x-prefixed 32-byte block hash
true = full tx objects, false = tx hashes only