hmyv2_getBlockByNumber

Get block by its index in the blockchain.

Parameters

  1. String - The block number.

  2. Boolean - If true, the returned block will contain all transactions in the block

Returns

  • number - Number: The block number. null when its pending block.

  • hash 32 Bytes - String: Hash of the block. null when its pending block.

  • parentHash 32 Bytes - String: Hash of the parent block.

  • nonce 8 Bytes - String: Hash of the generated proof-of-work. null when its pending block.

  • logsBloom 256 Bytes - String: The bloom filter for the logs of the block. null when its pending block.

  • transactionsRoot 32 Bytes - String: The root of the transaction trie of the block

  • stateRoot 32 Bytes - String: The root of the final state trie of the block.

  • miner - String: The address of the beneficiary to whom the mining rewards were given.

  • difficulty - String: Integer of the difficulty for this block.

  • extraData - String: The “extra data” field of this block.

  • size - Number: Integer the size of this block in bytes.

  • gasLimit - Number: The maximum gas allowed in this block.

  • gasUsed - Number: The total used gas by all transactions in this block.

  • timestamp - Number: The unix timestamp for when the block was collated.

  • stakingTransactions - Array: Array of staking transactions object; are present by default

  • transactions - Array: Array of transaction objects; absent if second parameter is false.

  • uncles - Array: Array of uncle hashes.

Example

//Request
curl --location --request POST 'http://<your-app-id>.ankr.com' --header 'Content-Type: application/json' --data-raw '{ "jsonrpc": "2.0", "id": 1, "method": "hmyv2_getBlockByNumber", "params": [ 1, { "fullTx": true, "inclTx": true, "InclStaking": true } ] }'
//Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difficulty": 0,
"epoch": 0,
"extraData": "0x",
"gasLimit": 4716988,
"gasUsed": 0,
"hash": "0xb7d7359c895324437af941838bdd44dbc03eb1a5ead433866bb117ea5a27318a",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "one1xdnm2fj6hyk7e49af2h9dmudkdlta9q354094e",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": 0,
"number": 1,
"parentHash": "0xdfeff1fba1aeed89fb75ef4ee9bf9e0fca1ff9b26d78d471565bf151f965274b",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"size": 601,
"stakingTransactions": [],
"stateRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"timestamp": 1561736307,
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": [],
"viewID": 0
}
}