pub async fn account_balance(
ledger_canister_id: Principal,
args: &AccountBalanceArgs,
) -> CallResult<Tokens>
Expand description
Calls the “account_balance” method on the specified canister.
§Example
use ic_cdk::api::msg_caller;
use ic_ledger_types::{AccountIdentifier, AccountBalanceArgs, Tokens, DEFAULT_SUBACCOUNT, MAINNET_LEDGER_CANISTER_ID, account_balance};
async fn check_callers_balance() -> Tokens {
account_balance(
MAINNET_LEDGER_CANISTER_ID,
&AccountBalanceArgs {
account: AccountIdentifier::new(&msg_caller(), &DEFAULT_SUBACCOUNT)
}
).await.expect("call to ledger failed")
}