eth_getBlockByNumber - Ethereum

Gives you the data about the block if you enter the block number

How to Use the eth_getBlockByNumber Method

Parameters

  • DATA, 32 Bytes - Block’s hash.

  • Boolean - In true cases – presents the full objects of a transaction. In false cases – recalls transactions’ hashes.

params: [
    '0x11a6c2c',
    true
]

What you receive

Object - A block object with all the fields below, or null if the block cannot be found:

  • number: QUANTITY - the number of a block. in case of a pending block, it returns null.

  • hash: DATA, 32 Bytes - block’s hash. in case of a pending block, it returns null.

  • parentHash: DATA, 32 Bytes - parent block’s hash.

  • nonce: DATA, 8 Bytes - the generated proof-of-work’s hash. in case of a pending block, it returns null.

  • sha3Uncles: DATA, 32 Bytes - he uncles data’s SHA3.

  • logsBloom: DATA, 256 Bytes - the logs of the block’s bloom filter. in case of a pending block, it returns null.

  • transactionsRoot: DATA, 32 Bytes - the transaction trie’s root.

  • stateRoot: DATA, 32 Bytes - the final state trie’s root.

  • receiptsRoot: DATA, 32 Bytes - the receipts trie’s root.

  • miner: DATA, 20 Bytes - the beneficiary's address that you are sending mining rewards to.

  • difficulty: QUANTITY - block’s difficulty level presented as an integer.

  • totalDifficulty: QUANTITY - the total chain’s difficulty level up tol this block presented as an integer.

  • extraData: DATA - a field for additional data in this block.

  • size: QUANTITY - integer the size of this block in bytes.

  • gasLimit: QUANTITY - the maximum amount of gas which is suitable in this block.

  • gasUsed: QUANTITY - the total amount of gas used for transactions in this block.

  • timestamp: QUANTITY - the collation time of the block presented as a unix timestamp.

  • transactions: Array - Array that includes objects for transactions, or 32 Bytes transaction hashes that depends on the last parameter you give.

  • uncles: Array - Array consisting of uncle hashes.

Sample

Here is a typical appliance example.

Call

curl https://eth-mainnet.rpcfast.com/?api_key=<key> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":0}'

Outcome

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "difficulty": "0x2d50ba175407",
    "extraData": "0xe4b883e5bda9e7a59ee4bb99e9b1bc",
    "gasLimit": "0x47e7c4",
    "gasUsed": "0x5208",
    "hash": "0xc0f4906fea23cf6f3cce98cb44e8e1449e455b28d684dfa9ff65426495584de6",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0x61c808d82a3ac53231750dadc13c777b59310bd9",
    "mixHash": "0xc38853328f753c455edaa4dfc6f62a435e05061beac136c13dbdcd0ff38e5f40",
    "nonce": "0x3b05c6d5524209f1",
    "number": "0x1e8480",
    "parentHash": "0x57ebf07eb9ed1137d41447020a25e51d30a0c272b5896571499c82c33ecb7288",
    "receiptsRoot": "0x84aea4a7aad5c5899bd5cfc7f309cc379009d30179316a2a7baa4a2ea4a438ac",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0x28a",
    "stateRoot": "0x96dbad955b166f5119793815c36f11ffa909859bbfeb64b735cca37cbf10bef1",
    "timestamp": "0x57a1118a",
    "totalDifficulty": "0x262c34a6fd1268f6c",
    "transactions": [
      "0xc55e2b90168af6972193c1f86fa4d7d7b31a29c156665d15b9cd48618b5177ef"
    ],
    "transactionsRoot": "0xb31f174d27b99cdae8e746bd138a01ce60d8dd7b224f7c60845914def05ecc58",
    "uncles": []
  }
}

Last updated