Amiya Behera
Amiya Behera

Reputation: 2270

How to get the near balance of an account near_sdk_sim?

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?

Upvotes: 2

Views: 312

Answers (1)

Ishamael
Ishamael

Reputation: 12795

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

bob.account().unwrap().amount

Upvotes: 1

Related Questions