L0vdL0vd

eth_getBlockByNumber

Returns a block by number.

归档 · 可查询任意历史区块

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["0x1208a5f",false]}'

响应示例

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "baseFeePerGas": "0x2c35b23c2",
    "difficulty": "0x0",
    "extraData": "0x4070656e6775696e6275696c642e6f7267",
    "gasLimit": "0x1c9c380",
    "gasUsed": "0xbe79ac",
    "hash": "0xc7a2fd354a9a1512636dad41b44e618905f5e8d2500f08c515c3bbbdf5261f6a",
    "logsBloom": "0x3525911ae0613375a2aa18f5863ab32838800fbddd5564c40d91621b9443135d749b2482eab0206c424c112c0e0041c72643c45ca801349d1789911101fee4004640641b107a0d7b68b0e34ddfa418a9544d119114c25e1664c1a427f87021a083e656cb…",
    "miner": "0xf15689636571dba322b48e9ec9ba6cfb3df818e1",
    "mixHash": "0x2813591c7fa6b60650d52a8258ac2a3e5f0d8b74b7fcf68820ad9525a54a1191",
    "nonce": "0x0000000000000000",
    "number": "0x1208a5f",
    "parentHash": "0xaa54d34d62525835280b02fc9662e022877698aadcd9a1e4644283d1ea32d206",
    "receiptsRoot": "0x02d59348a2e0d99bbe8489ef73ec56dad9f4d72b1fbcbe51beb314aa027f6102",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0xbe3d",
    "stateRoot": "0x68b96e88aca3010c517d787e5a0d94ada8bc5795cba44c45fa67b2e0c8f52e54",
    "timestamp": "0x65922b33",
    "transactions": [
      "0xbb62ecfc053ce6aa2f12dd09261e27e7c06b46dd015c67e28d5f7200bd6251ac",
      "0xda13880bec0b648aa3bbc5b036811443b036314da24a537daf251cf659f7404c"
    ],
    "transactionsRoot": "0xa280fc3336bf21914c79d3acaf7736332576cc6059157c23bc4e04d6a47b264f",
    "uncles": [],
    "withdrawals": [
      {
        "index": "0x1c9b8e6",
        "validatorIndex": "0x34ca0",
        "address": "0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f",
        "amount": "0x10cf12e"
      },
      {
        "index": "0x1c9b8e7",
        "validatorIndex": "0x34ca1",
        "address": "0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f",
        "amount": "0x10c527d"
      }
    ],
    "withdrawalsRoot": "0x7e4da59cfd250ceb7727e2e6194754f6ea6b63c69bd2b18a5e97135cd177f852"
  }
}

示例中较长的数组和十六进制字符串已截断。

参数与您的端点

参数

blockstring必填
Block number in hex (e.g. "0x1208a5f") or a tag: "latest", "safe", "finalized", "earliest" or "pending". L0vd endpoints run archive nodes, so any historical block works.
fullTransactionsboolean必填
true returns full transaction objects, false only their hashes.

返回值

object Block object, or null if the block does not exist.

numberstring
Block number, hex.
hashstring
Block hash.
parentHashstring
Hash of the parent block.
timestampstring
Unix timestamp, hex.
minerstring
Fee recipient address.
gasUsedstring
Total gas used by the block's transactions, hex.
gasLimitstring
Block gas limit, hex.
baseFeePerGasstring
EIP-1559 base fee, hex wei (London and later).
transactionsarray
Transaction hashes, or full transaction objects when the second parameter is true.
logsBloomstring
Bloom filter for the block's logs.
stateRootstring
Root of the state trie after the block.

适用场景

Read a block header and its transactions by number or tag.

Map blocks to timestamps, follow the chain head, or walk history block by block.

如何解读结果

Numbers are hex: timestamp 0x65922b33 is Unix time 1,704,078,131 (2024-01-01 03:02 UTC); baseFeePerGas is wei.

With fullTransactions = false you get transaction hashes only, which is much smaller. Use true when you need from, to, value and input for every transaction.

提示

  • Use "finalized" or "safe" when you must not see reorged data.
  • To get receipts for the whole block, call eth_getBlockReceipts instead of one receipt call per transaction.

相关方法