Skip to content

eth_getBlockByNumber

Returns information about a block by block number.

  1. QUANTITY|TAG — Integer of a block number, or the string "earliest", "latest", "safe", "finalized", or "pending".
  2. Boolean — If true, returns full transaction objects; if false, returns only transaction hashes.

Object|null — A block object, or null when no block was found.

FieldTypeDescription
numberQUANTITYBlock number
hashDATABlock hash
parentHashDATAParent block hash
timestampQUANTITYUnix timestamp
gasUsedQUANTITYGas used
gasLimitQUANTITYGas limit
baseFeePerGasQUANTITYBase fee (EIP-1559)
transactionsArrayTransaction hashes or objects
Terminal window
curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", false],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"number": "0x134e82a",
"hash": "0xabc...def",
"parentHash": "0x123...456",
"timestamp": "0x65a1b2c3",
"gasUsed": "0x1234",
"gasLimit": "0x1c9c380",
"baseFeePerGas": "0x3b9aca00",
"transactions": ["0x..."]
}
}
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");
const block = await provider.getBlock("latest");
console.log("Block:", block.number, "Txs:", block.transactions.length);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))
block = w3.eth.get_block("latest")
print(f"Block {block.number}{len(block.transactions)} txs")
MethodCost
eth_getBlockByNumber10 RU