Retrieve wallet balance

How to retrieve the native balance of a wallet

Intro

To fetch the balance of a wallet of a certain user you need to call the function getBalance, which will return a promise containing a WalletBalance object.

📘

🧙 If you only want to retrieve the balance of a user's wallet then getBalance is the perfect function, but if you also need to fetch his wallets or get some profile information, and maybe even need to authenticate the user, then it is recommended to retrieve the user account.

Function:

venlyConnect.api.getBalance("<WALLET_ID>");

Example:

const venlyConnect = new VenlyConnect('YOUR_CLIENT_ID'); 
venlyConnect.api.getBalance("d91b644a-076f-44bf-ae90-29251df19784").then((balance) => {
 console.log("The balance is",balance.balance);
})

Returns:

{
  available: true,
  secretType: "MATIC",
  balance: 0.06533725908157759,
  gasBalance: 0.06533725908157759,
  symbol: "POL",
  gasSymbol: "POL",
  rawBalance: "65337259081577592",
  rawGasBalance: "65337259081577592",
  decimals: 18
}

JS Fiddle Example

Function Reference

The function reference describes the different functions that are available in the Widget. For each function you can find the signature, its parameters, and possible options documented.

📘