Get the address balance

Get the list of address balance.

The API is used to get a list of address balance of wallet, Use the following code:

let walletInstance=await liminalJs
                                 .Coin(CoinsEnum.ltc)
                                 .Wallets()
                                 .Get({walletId:296});

let response=await walletInstance?.GetAddressBalance({
    pagination:{
      pageNumber:1,
      pageSize:100
    }
});

if(response.success){
  console.log("Response =>", JSON.stringify(response?.data?.AddressBalanceList));
}
else
{
  console.log("Error => ", JSON.stringify(response.message));
}
let walletInstance:Wallet=await liminalJs
                                 .Coin(CoinsEnum.ltc)
                                 .Wallets()
                                 .Get({walletId:296});

let response:GetAddressBalanceResultDataWrapper=await walletInstance?.GetAddressBalance({
    pagination:{
      pageNumber:1,
      pageSize:100
    }
});

if(response.success){
  console.log("Response =>", JSON.stringify(response?.data?.AddressBalanceList));
}
else
{
  console.log("Error => ", JSON.stringify(response.message));
}

Parameter:

Params

Data Type

Description

pageNumber

number

View a specific number of rows of the page.

pageSize

number

Restrict the number of rows to be returned. This optional parameter is not mandatory. If you do not pass this parameter value then SDK will set the default value as 250.

You will get the following response from the Get Address Balance method. It is JSON representation Only.

[
   {
      "address":"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj",
      "type":"receive",
      "path":"m/0/0",
      "balance":"0.09020031",
      "walletid":296
   }
]

Full Example

import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";

const main = async () => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
                clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
         let walletInstance=await liminalJs
                                         .Coin(CoinsEnum.ltc)
                                         .Wallets()
                                         .Get({walletId:296});

        // Get list of address balances
        let response=await walletInstance?.GetAddressBalance({
            pagination:{
              pageNumber:1,
              pageSize:100
            }
        });

        if(response.success){
          console.log("Response =>", JSON.stringify(response?.data?.AddressBalanceList));
        }
        else
        {
          console.log("Error => ", JSON.stringify(response.message));
        }
    }
    catch (ex) {
        throw ex;
    }
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
   CoinsEnum,LiminalEnvironment,
    LiminalJs,
    Wallet,
    GetAddressBalanceResultDataWrapper
} from "@lmnl/liminaljs"

const main = async (): Promise<void> => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
               clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance:Wallet=await liminalJs
                                        .Coin(CoinsEnum.ltc)
                                        .Wallets()
                                        .Get({walletId:296});

         // Get list of address balances
        let response:GetAddressBalanceResultDataWrapper=await walletInstance?.GetAddressBalance({
          pagination:{
            pageNumber:1,
            pageSize:100
          }
        });

        if(response.success){
          console.log("Response =>", JSON.stringify(response?.data?.AddressBalanceList));
        }
        else
        {
          console.log("Error => ", JSON.stringify(response.message));
        }

    }
    catch (ex) {
        throw ex;
    }
}

main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));

Get address balance bypassing address.

The API is used to get an address balance of the wallet bypassing address, Use the following code:

let walletInstance=await liminalJs
                                .Coin(CoinsEnum.ltc)
                                .Wallets()
                                .Get({walletId:296});

let response=await walletInstance?.GetAddressBalance({
  address:"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
});

if(response.success){
  console.log("Response =>", JSON.stringify(response?.data?.AddressBalance));
}
else
{
  console.log("Error => ", JSON.stringify(response.message));
}
let walletInstance:Wallet=await liminalJs
                                .Coin(CoinsEnum.ltc)
                                .Wallets()
                                .Get({walletId:296});

let response:GetAddressBalanceResultDataWrapper=await walletInstance?.GetAddressBalance({
  address:"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
});

if(response.success){
  console.log("Response =>", JSON.stringify(response?.data?.AddressBalance));
}
else
{
  console.log("Error => ", JSON.stringify(response.message));
}

Parameter:

Params

Data Type

Description

address

string

Address which will be used for information lookup.

You will get the following response from the Get Address Balance method. It is JSON representation Only.

{
  "address":"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj",
  "type":"receive",
  "path":"m/0/0",
  "balance":"0.09020031",
  "walletid":296
}

Full Example

import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";

const main = async () => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
                clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance=await liminalJs
                                        .Coin(CoinsEnum.ltc)
                                        .Wallets()
                                        .Get({walletId:296});

        //Get balance of address by passing address
        let response=await walletInstance?.GetAddressBalance({
          address:"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
        });

        if(response.success){
          console.log("Response =>", JSON.stringify(response?.data?.AddressBalance));
        }
        else
        {
          console.log("Error => ", JSON.stringify(response.message));
        }
    }
    catch (ex) {
        throw ex;
    }
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
   CoinsEnum,LiminalEnvironment,
    LiminalJs,
    Wallet,
    GetAddressBalanceResultDataWrapper
} from "@lmnl/liminaljs"

const main = async (): Promise<void> => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
               clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance:Wallet=await liminalJs
                                        .Coin(CoinsEnum.ltc)
                                        .Wallets()
                                        .Get({walletId:296});

       //Get balance of address by passing address
        let response:GetAddressBalanceResultDataWrapper=await walletInstance?.GetAddressBalance({
          address:"MVXHL4BFiE1BFc98eDoL1wTSXtfcdcSLqj"
        });

        if(response.success){
          console.log("Response =>", JSON.stringify(response?.data?.AddressBalance));
        }
        else
        {
          console.log("Error => ", JSON.stringify(response.message));
        }

    }
    catch (ex) {
        throw ex;
    }
}

main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));

Did this page help you?