eth_getBlockByNumber
Returns information about a block by number.

Example

Command Shell
Bash
1
curl https://bsc-<network>.web3api.com/v1/YOUR-API-KEY
2
-X POST
3
-H "Content-Type: application/json"
4
-d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\": [\"0x6F3225\", false],\"id\":1}"
Copied!
1
curl -X POST 'https://bsc-<network>.web3api.com/v1/YOUR-API-KEY' \
2
-H 'Content-Type: application/json' \
3
--data-raw '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params": ["0x6F3225", false],"id":1}'
Copied!
Request
Response
  1. 1.
    BLOCK PARAMETER - An int block number in the form of hex, appended with 0x such as 0x6D7FE0, or pre-defined strings latest, earliest, pending.
  2. 2.
    SHOW TRANSACTION DETAILS FLAG - A boolean parameter. When true, returns the full transaction information of each transaction hash included within the block. When false, only returns transaction hashes within the block.
Web3API's Composer accepts int block numbers, which will be auto-converted to a hex representation before being sent to a node.
Result Fields
BLOCK - A block object, or null when no block was found with the number specified.
Within the block object, the following block information are available.
  1. 1.
    difficulty: integer of the difficulty for this block.
  2. 2.
    extraData: the "extra data" field of this block.
  3. 3.
    gasLimit: the maximum gas allowed in this block.
  4. 4.
    gasUsed: the total used gas by all transactions in this block.
  5. 5.
    hash: 32 Bytes - hash of the block. Null when the returned block is the pending block.
  6. 6.
    logsBloom: 256 Bytes - the bloom filter for the logs of the block. Null when the returned block is the pending block.
  7. 7.
    miner: 20 Bytes - the address of the beneficiary to whom the mining rewards were given.
  8. 8.
    mixHash -
  9. 9.
    nonce: 8 Bytes - hash of the generated proof-of-work. Null when the returned block is the pending block.
  10. 10.
    number: the block number. Null when the returned block is the pending block.
  11. 11.
    parentHash: 32 Bytes - hash of the parent block.
  12. 12.
    receiptsRoot: 32 Bytes - the root of the receipts trie of the block.
  13. 13.
    sha3Uncles: 32 Bytes - SHA3 of the uncles data in the block.
  14. 14.
    size: integer the size of this block in bytes.
  15. 15.
    stateRoot: 32 Bytes - the root of the final state trie of the block.
  16. 16.
    timestamp: the unix timestamp for when the block was collated.
  17. 17.
    totalDifficulty: integer of the total difficulty of the chain until this block.
  18. 18.
    transactions: Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
  19. 19.
    transactionsRoot: 32 Bytes - the root of the transaction trie of the block.
  20. 20.
    uncles: an Array of uncle hashes.
Body
1
{
2
"jsonrpc":"2.0",
3
"id":1,
4
"result":{
5
"difficulty":"0x2",
6
"extraData":"0xd883010007846765746888676f312e31352e35856c696e7578000000fc3ca6b7c2bfa0f0018488d389673b8267cc1eb7d25c0a16e92889dafa8fbd5446d55a004602c9f8c3ac3444610d8a3091376fe87d29e44bb88d5dec0b885b718ca1f36700",
7
"gasLimit":"0x2dc9ffa",
8
"gasUsed":"0x1e60464",
9
"hash":"0x1fb2230a6b5bf856bb4df3c80cbf95b84454169a5a133fffaf8505a05f960aeb",
10
"logsBloom":"0x8deb8ebc5ffd151c0764c558d00009996a5a967dce4cfa333378b128eecf03243b19d66ebc1e1d677d69fcea9e8b0722ede6bc11ba22289b0710bdf5663f72e9b27f7b57d3859c83e5bbee9a1efb98f6fe1f49a8dc6ed96bdf04ba79d077fe75ebaff72dbf5ac9eb9faaf2c33d254bf2cb3597dda5be3ff19e7f7c9794d6c5bfc2649af11955981169af274e3db41cb34c66dc85fa39cbdc7f81295cea20edd25b5a25d2e9c14d4d064ecf48b2ceee7972658213df605b661fff23aa00b013e634df65ee9200791f7595358b2fc7f17def555e1194a196b27a32f8fbe9eee19f76b94e3284d0450b493ab4ab3f640fb066bdff7dcbcbf37be82636991ff8e4ee",
11
"miner":"0x7ae2f5b9e386cd1b50a4550696d957cb4900f03a",
12
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
13
"nonce":"0x0000000000000000",
14
"number":"0x6e05b6",
15
"parentHash":"0x67551efb54174d16002405e2847756e4e7555cfca44ff5823c695a8c07992c5a",
16
"receiptsRoot":"0x01e794163bb70020ad2286149bd4794827aa560ca41be6f0f606e7ac50ad1734",
17
"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
18
"size":"0x17faa",
19
"stateRoot":"0xc1414eee14dc067b8044f398f5a9b123edc56130f91a2114515d901d387a4852",
20
"timestamp":"0x60950792",
21
"totalDifficulty":"0xdb7f02",
22
"transactions":[
23
"0x2fa91f0bd9dc0ac4c3809efa40778d518968497bc585d3b478559e4cd55f4a23",
24
"0x6232bd82064c316cd7ece24e8e2025670a53d31574f20f9da2b857d64f972d30",
25
"0xef1ad0aa81163162ca013c375ce222a09eae4ebe8f7b567b72905e11f1258ba1",
26
],
27
"transactionsRoot":"0x0f2b87218f5f85740725b04f911f6027c34ebeba808f84d02d6afb17f06399af",
28
"uncles":[
29
]
30
}
31
}
Copied!
Last modified 5mo ago
Copy link