pub fn balance_of(target: ContractId, asset_id: AssetId) -> u64 
Expand description

Get the balance of coin asset_id for the contract at ‘target’.

Arguments

  • target: [ContractId] - The contract that contains the asset_id.
  • asset_id: [AssetId] - The asset of which the balance should be returned.

Returns

  • [u64] - The amount of the asset which the target holds.

Examples

use std::{asset::mint, call_frames::contract_id, constants::DEFAULT_SUB_ID, context::balance_of};

fn foo() {
    mint(DEFAULT_SUB_ID, 50);
    let asset_id = AssetId::default();
    assert(balance_of(contract_id(), asset_id) == 50);
}