getBalance static method

Future<ICPTs> getBalance({
  1. required AgentFactory agent,
  2. required String accountId,
  3. SignIdentity? identity,
})

Implementation

static Future<ICPTs> getBalance({
  required AgentFactory agent,
  required String accountId,
  SignIdentity? identity,
}) async {
  final ledgerInstance = Ledger.hook(agent)..setIdentity(identity);
  final res = await ledgerInstance.agent.actor!.getFunc(
    LedgerMethods.getBalance,
  )!([AccountBalanceArgs(account: accountId).toJson()]);
  if (res != null) {
    return ICPTs.fromJson(res);
  }
  throw StateError('Request failed with the result: $res.');
}