🔗near

Description

The getBalanceByMnemonic function is used to retrieve the account balance associated with a specified mnemonic and account ID. It allows you to query the balance of a Near Protocol account by providing the mnemonic, the account ID, and the environment (e.g., testnet, mainnet) in which the account exists.

Parameters

ParameterData TypeDescription

blockchain

string

The blockchain network associated with the mnemonic (in this case, near)

mnemonic

string

The mnemonic associated with the Near Protocol account.

accountId

string

The ID of the Near Protocol account.

Response

FieldData TypeDescription

total

numeric

The total balance of the specified Near Protocol account.

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 txStatus request using the Nest SDK:

// import wallet from the nest SDK
const { Wallet } = require('@nest25/wallet-lib');
// create a new wallet instance
const wallet = new Wallet('');
// set the mnemonic to use for the wallet
const testMnemonic = 'exchange fun mixed elevator laundry length trap script boost purchase genuine arrest';

async function main() {
  // get the balance of the wallet
  const response = await wallet.getBalanceByMnemonic(
    'near',
    testMnemonic,
    'tomarc',
  );
  // log the response
  console.log(response);
}

Response

  

Use Cases

  • Online Wallets: Online wallets can use this function to retrieve the status of transactions made on their platform. By querying the account balance using the getBalanceByMnemonic function, online wallets can provide users with real-time information about their account balances.

  • Trading Platforms: Trading platforms can use this function to verify the status of transactions made by their users on different blockchain networks. By checking the account balance of a specific Near Protocol account using the getBalanceByMnemonic function, trading platforms can ensure that the necessary funds are available for executing transactions and updating the user's portfolio accordingly.

Last updated