Function ic_ledger_types::account_balance[][src]

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::{caller, call::call};
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(&caller(), &DEFAULT_SUBACCOUNT)
    }
  ).await.expect("call to ledger failed")
}