Get Balance
Get Balance
The API is used to get the balance of the wallet.
// Get Balance
let response=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
// Get Balance
let response:GetBalanceResultDataWrapper=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
Sample response
{
"chain":"LTC",
"coin":"LTC",
"symbol":"LTC",
"balanceString":"0.09116981",
"confirmedBalanceString":"0.09116981",
"spendableBalance":"0.09116981",
"balanceInLowerDenom":"9116981",
"confirmedBalanceInLowerDenom":"9116981",
"spendableBalanceInLowerDenom":"9116981"
}
Full Example
import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";
const main = async () => {
try {
// Instance of Liminal Js
let liminalJs = new LiminalJs(LiminalEnvironment.test);
await liminalJs
.Authenticate({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET"
})
.AuthenticateWithAccessToken();
// Get Wallet Instance
let walletInstance = await liminalJs
.Coin(CoinsEnum.ltc)
.Wallets()
.Get({ walletId: 296 });
// Get Balance
let response=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
}
catch (ex) {
throw ex;
}
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
AddressType, CoinsEnum,LiminalEnvironment,
LiminalJs,
Wallet,
WalletResult,
GetBalanceResultDataWrapper
} from "@lmnl/liminaljs"
const main = async (): Promise<void> => {
try {
// Instance of Liminal Js
let liminalJs = new LiminalJs(LiminalEnvironment.test);
await liminalJs
.Authenticate({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET"
})
.AuthenticateWithAccessToken();
// Get Wallet Instance
let walletInstance: Wallet = await liminalJs
.Coin(CoinsEnum.ltc)
.Wallets()
.Get({ walletId: 296 });
// Get Balance
let response:GetBalanceResultDataWrapper=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
}
catch (ex) {
throw ex;
}
}
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
ERC20 Token
To get the balance of the ERC20 Tokens.
// Get Wallet Instance
let walletInstance=await liminalJs
.Coin(CoinsEnum.eth)
.Token({
tokenName:"bat",
tokenAddress:"0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99"
})
.Wallets()
.Get({walletId:310});
// Get Balance
let response=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
// Get Wallet Instance
let walletInstance:Wallet=await liminalJs
.Coin(CoinsEnum.eth)
.Token({
tokenName:"bat",
tokenAddress:"0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99"
})
.Wallets()
.Get({walletId:310});
// Get Balance
let response:GetBalanceResultDataWrapper=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
Sample response received
{
"symbol":"BAT",
"balanceString":"68.00099000",
"confirmedBalanceString":"68.00099000",
"spendableBalance":"68.00099000",
"balanceInLowerDenom":"68000990000000000000",
"confirmedBalanceInLowerDenom":"68000990000000000000",
"spendableBalanceInLowerDenom":"68000990000000000000",
"identifier":"0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99",
"decimalplaces":"18",
"nativeCoin":{
"chain":"ETH",
"coin":"ETH",
"symbol":"ETH",
"balanceString":"0.47909433",
"confirmedBalanceString":"0.47909433",
"spendableBalance":"0.47909433",
"balanceInLowerDenom":"479094330000000000",
"confirmedBalanceInLowerDenom":"479094330000000000",
"spendableBalanceInLowerDenom":"479094330000000000"
}
}
Full Example
import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";
const main = async () => {
try {
// Instance of Liminal Js
let liminalJs = new LiminalJs(LiminalEnvironment.test);
await liminalJs
.Authenticate({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET"
})
.AuthenticateWithAccessToken();
// Get Wallet Instance
let walletInstance=await liminalJs
.Coin(CoinsEnum.eth)
.Token({
tokenName:"bat",
tokenAddress:"0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99"
})
.Wallets()
.Get({walletId:310});
// Get Balance
let response=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
}
catch (ex) {
throw ex;
}
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
AddressType, CoinsEnum,LiminalEnvironment,
LiminalJs,
Wallet,
WalletResult,
GetBalanceResultDataWrapper
} from "@lmnl/liminaljs"
const main = async (): Promise<void> => {
try {
// Instance of Liminal Js
let liminalJs = new LiminalJs(LiminalEnvironment.test);
await liminalJs
.Authenticate({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET"
})
.AuthenticateWithAccessToken();
// Get Wallet Instance
let walletInstance:Wallet=await liminalJs
.Coin(CoinsEnum.eth)
.Token({
tokenName:"bat",
tokenAddress:"0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99"
})
.Wallets()
.Get({walletId:310});
// Get Balance
let response:GetBalanceResultDataWrapper=await walletInstance?.GetBalance();
console.log("Response =>", JSON.stringify(response));
}
catch (ex) {
throw ex;
}
}
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
Updated 4 days ago
Did this page help you?