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": '3f403b28a967623c6d08a6be73db9f7094095e513f20e5c0r2e30fcde33b33f7',
      "parent_hash": 'f84d4332cdce09f8ccu5fff4ac1d2ddbe504ee75fe8d6a7a77837a5ac5b678b4',
      "timestamp": 1706092786368404,
      "transactions": [],
      "block_type": 0,
      "cluster_address": '0101010101010101010101010101010101010101'
    }
}

Last updated