How to get block information by block number?

  • getBlockByNumber

This function is used to retrieve information about a block by its block number.

import { L1XProvider } from "@l1x/l1x-wallet-sdk";

let l1xProvider = new L1XProvider({
  clusterType: "mainnet",
    endpoint: "https://v2-mainnet-rpc.l1x.foundation",

});

l1xProvider.core
  .getBlockByNumber({ block_number: "492" })
  .then((response) => console.log(response))    // log response
  .catch((err) => console.error(err));          // log error
  

Parameters:

The account state request parameters.

{
    "block_number": "492"
}

Returns:

A promise that resolves with the account state response

{
    "block": {
      "number": '492',
      "hash": 'd7dec6c4112ebf962b33b0eec31cbd53c58fa5c8872b18b14437ce03c5357f18',
      "parent_hash": 'd7dec6c4112ebf962b33b0eec31cbd53c58fa5c8872b18b14437ce03c5357f18',
      "timestamp": 1706092786368404,
      "transactions": [],
      "block_type": 0,
      "cluster_address": '0101010101010101010101010101010101010101'
    }
}

Last updated