🔗btc

Description

The getBalanceByMnemonic function retrieves the balance of a specific address associated with a mnemonic phrase on the Solana Blockchain.

Parameters

ParameterData TypeDescription

blockchain

string

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

mnemonic

string

The mnemonic phrase used to derive the address.

Response

FieldData TypeDescription

code

number

The status code indicating the success or failure.

result

number

The balance of the specified address in the network.

error

any

An error object containing details if an error occurs.

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

Response

  

Use Cases

  • Cryptocurrency Exchanges: Cryptocurrency exchanges can employ this function to fetch the balance of users' addresses associated with their mnemonic phrases. This information is crucial for displaying accurate wallet balances, calculating available funds for trading, and managing user accounts.

  • Blockchain Explorers: Blockchain explorers can utilize this function to provide users with real-time balance information for specific addresses. By integrating this function, blockchain explorers can display the current balance of any address based on the mnemonic phrase provided.

  • Decentralized Applications (DApps): DApps running on blockchain networks can make use of this function to retrieve the balance associated with the user's address derived from their mnemonic phrase. This balance information is vital for displaying account balances within the DApp, enabling users to manage their funds and interact with the application seamlessly.

Last updated