🔗evm

Description

The getBalanceByMnemonic function is used to retrieve the balance of a wallet address associated with a given mnemonic phrase.

Parameters

ParameterData TypeDescription

blockchain

string

The name of the blockchain network.

mnemonic

string

The mnemonic phrase associated with the wallet.

env

string

The environment or network configuration.

Response

FieldData TypeDescription

code

number

The status code indicating the result of the operation.

result

any

The balance of the wallet address in the specified network.

error

any

An error message or object if an error occurs during the operation.

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:

// 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('ava', testMnemonic);
  // log the response
  console.log(response);
}
main()

Response

  

Use Cases

  • Online Wallets: By providing the mnemonic, the online wallet service can obtain the balance of a wallet address associated with a specific user. This information can be used to display the available balance to the user, track transaction history, or perform further operations related to the wallet.

  • Trading Platforms: Trading platforms can utilize this function to verify the status of transactions made by their users on different blockchain networks. By utilizing the getBalanceByMnemonic function with the appropriate blockchain and mnemonic, the trading platform can fetch the balance of a user's wallet address.

Last updated