How to use it

// yarn add @tatumio/tatum

import { TatumSDK, Klaytn, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<Klaytn>({network: Network.KLAYTN})

const block = await tatum.rpc.getBlockByNumber('latest', true)

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs


klay_getBlockByNumber is an JSON-RPC method that allows developers to query a specific block in the blockchain by its block number. This method can be used in various scenarios, such as analyzing historical transactions, validating the state of the blockchain, or monitoring the progress of mining activities.


There are two required parameters for this method:

  1. blockNumber - The block number of the block to be retrieved. This can be a hexadecimal string or one of the predefined aliases: "earliest", "latest", or "pending".

    Example: "0x1b4"

  2. returnFullTransactionObjects - A boolean value that determines whether the returned block contains complete transaction objects (true) or only transaction hashes (false).

    Example: true

Return Object

The returned block object includes the following fields:

  • number - The block number (hexadecimal string).

  • hash - The block hash (32-byte string).

  • parentHash - The hash of the parent block (32-byte string).

  • nonce - The nonce used to generate the block (8-byte string).

  • sha3Uncles - The SHA3 hash of the uncles in the block (32-byte string).

  • logsBloom - The logs bloom filter of the block (256-byte string).

  • transactionsRoot - The root of the transaction trie (32-byte string).

  • stateRoot - The root of the state trie (32-byte string).

  • miner - The address of the miner who mined the block (20-byte string).

  • difficulty - The difficulty of the block (hexadecimal string).

  • totalDifficulty - The total difficulty of the chain up to this block (hexadecimal string).

  • extraData - Extra data included by the miner in the block (byte string).

  • size - The block size in bytes (hexadecimal string).

  • gasLimit - The gas limit for the block (hexadecimal string).

  • gasUsed - The total gas used by all transactions in the block (hexadecimal string).

  • timestamp - The block timestamp (hexadecimal string).

  • transactions - An array of transaction objects or transaction hashes, depending on the returnFullTransactionObjects parameter.

  • uncles - An array of uncle block hashes (32-byte strings).

If returnFullTransactionObjects is true, the transactions field contains transaction objects with the following fields:

  • hash - The transaction hash (32-byte string).

  • nonce - The number of transactions sent by the sender before this transaction (hexadecimal string).

  • blockHash - The block hash where the transaction is included (32-byte string).

  • blockNumber - The block number where the transaction is included (hexadecimal string).

  • transactionIndex - The index of the transaction in the block (hexadecimal string).

  • from - The sender address (20-byte string).

  • to - The recipient address, or null for contract creation transactions (20-byte string).

  • value - The value being transferred (hexadecimal string).

  • gasPrice - The gas price in wei (hexadecimal string).

  • gas - The gas provided for the transaction (hexadecimal string).

  • input - The input data for the transaction (byte string).

JSON-RPC Request and Response Examples

Here are examples of JSON-RPC request and response for the klay_getBlockByNumber method:


  "id": 1,
  "jsonrpc": "2.0",
  "method": "klay_getBlockByNumber",
  "params": ["latest", true]


    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "difficulty": "0x2",
        "extraData": "0xd883010114846765746888676f312e31392e36856c696e75780000008279af9a2f9343c00920c795a7abe84303ee56588946383a15d1e9ee422a7df6dcbe199e4ec93511fe1ffa3c3ab10cb5b12459e8f64553ad3a741e9562e1d5e522c336a400",
        "gasLimit": "0x2faed85",
        "gasUsed": "0xd81f1",
        "hash": "0x078610ca461480e4b78557f20e544084cccc4accb41f5c1b7ef792246b78c94b",
        "logsBloom": "0x0020001000000000000001000000000000000000000000040000000000084000000004000800000000c06100800000000000000000010000200000000024008000004000000000000000001800001000a0500000000400040000000000000000000002200202000000000000004008000800080000000000000010100040004000000000000100000000000000000000000024000000080000000080000000210220000