Embedded Wallets
SDK
Javascript
How to
Wallet Operation
Check Balance Coin

Check Balance Coin

This method allows you to check your native balance coin from a blockchain network.

Method Signature

async balanceCoin({ network: Network, walletToken: string, refreshToken?: string} ): Promise<CheckBalanceResponse>

Parameters

  • network: Network - The network used for transactions. You can use the Network enum to specify the network.
  • walletToken: string - The wallet token of the wallet to check the balance for.
  • refreshToken: string (optional) - The refresh token for authentication. Use this if you want to allow SDK automatically refresh the wallet token.

Returns

Promise<CheckBalanceResponse> - An object containing the following properties:

  • balance: string - The balance of the native coin.
  • symbol: string - The symbol of the native coin.
  • address: string - The wallet address.
  • walletToken: string - The new wallet token of the wallet.
  • refreshToken?: string - The new refresh token of the wallet.

Example Usage

const balanceInfo = await sdk.wallet.balanceCoin({ 
  network: Network.ETHEREUM, 
  walletToken: 'your-wallet-token', 
  refreshToken: 'your-refresh-token' // Optional
});
console.log(balanceInfo);

Response Example

{
  "balance": "0.02",
  "symbol": "ETH",
  "address": "0xBfE64B4b628E0998A03e2522B051Cf1B4661c964",
  "walletToken": "your-new-wallet-token",
  "refreshToken": "your-new-refresh-token"
}
ℹ️

The SDK will automatically refresh the wallet token and return the new wallet token and refresh token if the refresh token is provided.

ℹ️

The response is an object containing the balance, symbol, and address of the native coin for the specified network.

Additional Information

  • This method requires a valid wallet token in the SDK configuration.
  • The balance is returned as a string to preserve precision for large numbers.
  • The network parameter determines which blockchain network's balance will be checked.

For more information, see the Xellar Check Balance Coin API Documentation (opens in a new tab).