eth_getBlockByHash
Returns information about a block by block hash.
Parameters
Section titled “Parameters”DATA(32 bytes) — Hash of a block.Boolean— Iftrue, returns full transaction objects; iffalse, returns only transaction hashes.
Returns
Section titled “Returns”Object|null — A block object (same structure as eth_getBlockByNumber), or null when no block was found.
Request
Section titled “Request”curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "eth_getBlockByHash", "params": ["0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae", false], "id": 1 }'Code Examples
Section titled “Code Examples”JavaScript (ethers.js v6)
Section titled “JavaScript (ethers.js v6)”import { JsonRpcProvider } from "ethers";const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");const block = await provider.getBlock("0xdc0818cf...");console.log("Block number:", block.number);Python (web3.py)
Section titled “Python (web3.py)”from web3 import Web3w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))block = w3.eth.get_block("0xdc0818cf...")print(f"Block number: {block.number}")RU Cost
Section titled “RU Cost”| Method | Cost |
|---|---|
| eth_getBlockByHash | 10 RU |