accountBalance static method
Future<Tokens>
accountBalance({
- required AgentFactory agent,
- required String accountIdOrPrincipal,
- SignIdentity? identity,
Implementation
static Future<Tokens> accountBalance({
required AgentFactory agent,
required String accountIdOrPrincipal,
SignIdentity? identity,
}) async {
final ledgerInstance = Ledger.hook(agent)..setIdentity(identity);
final accountId = isHex(accountIdOrPrincipal)
? accountIdOrPrincipal.toU8a().toList()
: Principal.fromText(accountIdOrPrincipal).toAccountId().toList();
final res = await ledgerInstance.agent.actor!
.getFunc(LedgerMethods.accountBalance)!(
[AccountBalanceArgsNew(account: accountId).toJson()],
);
if (res != null) {
return Tokens.fromJson(res);
}
throw StateError('Request failed with the result: $res.');
}