eth_getBlockByNumber

Returns information of the block matching the given block number.

📘

Supported on Avalanche C-Chain (mainnet) only.

Parameters

  • quantity or tag - Integer block number, or the string 'latest', 'earliest' or 'pending'.
  • boolean - If true it returns the full transaction objects, if false only the hashes of the transactions.

Returns

  • object - A block object, or ‘null’ when no block was found.
    • number - The block number of the requested block encoded as a hexadecimal. null when its pending block.
    • hash - The block hash of the requested block. null when its pending block.
    • parenthash - Hash of the parent block.
    • nonce - Hash of the generated proof-of-work. null if pending.
    • sha3uncles - SHA3 of the uncles data in the block.
    • logsbloom - The bloom filter for the logs of the block. null if pending.
    • transactionsroot - The root of the transaction trie of the block.
    • stateroot - The root of the final state trie of the block.
    • receiptsroot - The root of the receipts trie of the block.
    • miner - The address of the beneficiary to whom the mining rewards were given.
    • difficulty - Integer of the difficulty for this block encoded as a hexadecimal.
    • totaldifficulty - Integer of the total difficulty of the chain until this block encoded as a hexadecimal.
    • extradata - The “extra data” field of this block.
    • size - The size of this block in bytes as an Integer value encoded as hexadecimal.
    • gaslimit - The maximum gas allowed in this block encoded as a hexadecimal.
    • gasused - The total used gas by all transactions in this block encoded as a hexadecimal.
    • timestamp - The unix timestamp for when the block was collated.
    • transactions - Array of transaction objects, or 32 Bytes transaction hashes depending on the second Boolean parameter in request.
    • uncles - Array of uncle hashes.

API Endpoint

The format of an Avalanche C-Chain API endpoint is
https://open-platform.nodereal.io/{{apiKey}}/avalanche-c/ext/bc/C/rpc - for RPC API
https://open-platform.nodereal.io/{{apiKey}}/avalanche-c/ext/bc/C/avax - for AVAX API

Here is an example:
https://open-platform.nodereal.io/4c0a1c23661a4e26bcbcwed461e34ea9/avalanche-c/ext/bc/C/rpc
https://open-platform.nodereal.io/4c0a1c23661a4e26bcbcwed461e34ea9/avalanche-c/ext/bc/C/avax

Example

Request

curl https://open-platform.nodereal.io/{{apiKey}}/avalanche-c/ext/bc/C/rpc \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"method":"eth_getBlockByNumber","params":["0xc5043f",false],"id":1,"jsonrpc":"2.0"}'

Result

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": null
}