How to get Account State?

  • getAccountState:

Retrieves the account state information from the L1X Core blockchain.

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

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

const accountStateRequest: GetAccountStateArg = {
  address: "6e371a05d5766c692172744f4907940ef324fcb9",
};

l1xProvider.core
  .getAccountState(accountStateRequest)
  .then((response) => console.log(response))    // log response
  .catch((err) => console.error(err));          // log error

Parameters:

The account state request parameters.

{
    "address": "6e371a05d5766c692172744f4907940ef324fcb9"
}

Returns:

A promise that resolves with the account state response.

{
   "account_state":{
      "balance":"158",
      "nonce":0,
      "account_type":1,
      "balance_formatted":"158000000000000000000"
   }
}

Last updated