🔗evm

Description

The getTotalBalanceInUSDbyAddressArray function is an asynchronous function used to retrieve the total balance in USD for a given array of Ethereum and Solana addresses.

Parameters

ParameterData TypeDescription

addresses

string[]

(Optional) An array of Ethereum addresses for which the total balance is requested.

solanaAddresses

string[]

(Optional) An array of Solana addresses for which the total balance is requested.

Response

FieldData TypeDescription

code

number

Indicates the status code. 1 for success, 0 for error.

result

object

Contains the total balance in USD for the provided addresses.

error

string

Contains the error message if an error occurred during the process.

Example Request and Response

Prerequisites

Before making requests with Nest SDK, you must have it installed.

You can install Nest SDK using either npm or yarn. Use the following commands to install Nest SDK:

npm install @nest25/wallet-lib
OR
yarn add @nest25/wallet-lib

Request

Here is an example of how to make a getBalanceByMnemonicrequest using the Nest SDK:

const { Wallet } = require('@nest25/wallet-lib');

const wallet = new Wallet('');

async function main() {
    const addresses = ['0x97Be6D5204A57b8384c15500c38295306243d154', '0x91e803036F3c0628406d8f032e883E21564a8C48'];

    const solanaAddresses = [
      'DqKvT89ndGomiUvPbUfJc8gLFmkKci8HdBJHekZt6kb7',
      '9jBxBwCHt6R5CgxhpjH43M6141JMCdjccjfWufnEB2r8',
    ];
  
    const response = await wallet.getTotalBalanceInUSDbyAddressArray(addresses, solanaAddresses);
    console.log("response --> ", response);
}

main();

Response

   response -->  {
        code: 1,
        result: [
          {
            address: '0x97Be6D5204A57b8384c15500c38295306243d154',
            solanaAddress: null,
            balances: [Array],
            totalBalance: 0
          },
          {
            address: '0x91e803036F3c0628406d8f032e883E21564a8C48',
            solanaAddress: null,
            balances: [Array],
            totalBalance: 98.93
          },
          {
            address: null,
            solanaAddress: 'DqKvT89ndGomiUvPbUfJc8gLFmkKci8HdBJHekZt6kb7',
            balances: [Array],
            totalBalance: 0
          },
          {
            address: null,
            solanaAddress: '9jBxBwCHt6R5CgxhpjH43M6141JMCdjccjfWufnEB2r8',
            balances: [Array],
            totalBalance: 0
          }
        ]
      }

Use Cases

  • Retrieving total balance: By invoking this function with an array of Ethereum and/or Solana addresses, you can retrieve the total balance in USD for those addresses.

  • Error handling: If there is an error during the API request or if the response status code is not 1, the function will return an error object with the appropriate error message.

Last updated