How to get the near balance of an account near_sdk_sim?

Viewed 169

Getting balance of fungible token in near_sdk_sim is

let bob = root.create_user("bob".to_string(), to_yocto("1000000"));    
let bob_balance: U128 =
            view!(contract.ft_balance_of(bob.valid_account_id())).unwrap_json();
assert_eq!(bob_balance.0, 5000);

But how to get the near balance of account bob?

1 Answers

Get the account info via account method (doc). It returns an Option<Account>, Account has an amount field.

bob.account().unwrap().amount
Related