get_header_by_number - Nervos

Returns the block header in the canonical chain with the specific block number.

Parameters

  • block_number - Number of a block.
  • verbosity - Result format which allows 0 and 1. (Optional, the default is 1.)

Returns

The RPC returns the block header when block_number is less than or equal to the tip block number returned by get_tip_block_number and returns null otherwise.

Because of chain reorganization, the PRC may return null or even different block headers in different invocations with the same block_number.

When verbosity is 1, it returns a JSON object as the result. See HeaderView for the schema.

When verbosity is 0, it returns a 0x-prefixed hex string as the result. The string encodes the block header serialized by molecule using schema table Header.

Example

Request

curl --location --request POST 'https://ckb-mirana.unifra.io/v1/4fb36720a57340d39aee4cf68511064a' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "get_header_by_number",
  "params": [
    "0x400"
  ]
}'

Result

{
    "jsonrpc": "2.0",
    "result": {
        "compact_target": "0x1a08a97e",
        "dao": "0x7194050c98a5a12e4827806b0b872300b2e0a033e71b0000008867461f3bff06",
        "epoch": "0x6cf0400000000",
        "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "hash": "0xb2671d3cc16b7738bbc8902ef11322bc2bfe7c54f5ce4a5cdfdf57b1a02fcb11",
        "nonce": "0x5af1702d0000043000000000cc700400",
        "number": "0x400",
        "parent_hash": "0x013c445cedc6744f051a78320217e2493590d014fa49e9815481954a68a2a18d",
        "proposals_hash": "0xc78954b079452667f9e2412af83893b6ccdf93e7fc21f88b015f58f677c8e2e2",
        "timestamp": "0x16e7808ab0f",
        "transactions_root": "0x535c2a0979a61c984b862a93198b2055c20e8b57db6dbb184cbadcee339bcc92",
        "version": "0x0"
    },
    "id": 42
}
Language
Click Try It! to start a request and see the response here!