Check Balance
You can retrieve the balance for any account you created by calling the
Account.balance()
function. Bear in mind that you should always sync the account with the node to get the latest
outputs. The sync function also returns the balance. So in some cases just calling that might be enough.
Online Faucet
You can request test funds from the Shimmer Testnet Faucet.
Code Example
The following example will:
- Create a wallet.
- Get Alice's account which was created in the first guide.
- Sync the account with the node to get the latest transactions.
- Request the account's balance.
- Rust
- Nodejs
- Python
sdk/examples/how_tos/accounts_and_addresses/check_balance.rs
loading...
bindings/nodejs/examples/how_tos/accounts_and_addresses/check-balance.ts
loading...
bindings/python/examples/how_tos/accounts_and_addresses/check_balance.py
loading...
Expected Output
- Rust
- Nodejs
- Python
Balance {
base_coin: BaseCoinBalance {
total: 1398000000,
available: 1398000000,
},
required_storage_deposit: RequiredStorageDeposit {
alias: 0,
basic: 213000,
foundry: 0,
nft: 0,
},
native_tokens: [],
nfts: [],
aliases: [],
foundries: [],
potentially_locked_outputs: {},
}
Balance {
baseCoin: { total: '1398000000', available: '1398000000', votingPower: '0'
},
requiredStorageDeposit: {
alias: '0',
basic: '213000',
foundry: '0',
nft: '0'
},
nativeTokens: [],
nfts: [],
aliases: [],
foundries: [],
potentiallyLockedOutputs: {}
}
Balance {
"baseCoin": {
"total": "1398000000",
"available": "1398000000"
},
"requiredStorageDeposit": {
"alias": "0",
"basic": "213000",
"foundry": "0",
"nft": "0"
},
"nativeTokens": [],
"nfts": [],
"aliases": [],
"foundries": [],
"potentiallyLockedOutputs": {}
}