pub fn _mint(
    total_assets_key: StorageKey<u64>,
    total_supply_key: StorageKey<StorageMap<AssetId, u64>>,
    recipient: Identity,
    sub_id: SubId,
    amount: u64,
) -> AssetId 
Expand description

Unconditionally mints new assets using the sub_id sub-identifier.

Additional Information

Warning This function increases the total supply by the number of coins minted.

Arguments

  • total_assets_key: [StorageKey] - The location in storage that the u64 which represents the total assets is stored.
  • total_supply_key: [StorageKey<StorageMap<AssetId, u64>>] - The location in storage which the StorageMap that stores the total supply of assets is stored.
  • recipient: [Identity] - The user to which the newly minted asset is transferred to.
  • sub_id: [SubId] - The sub-identifier of the newly minted asset.
  • amount: [u64] - The quantity of coins to mint.

Returns

  • [AssetId] - The AssetId of the newly minted asset.

Number of Storage Accesses

  • Reads: 2
  • Writes: 2

Examples

use sway_libs::asset::supply::_mint;
use std::context::balance_of;

storage {
    total_assets: u64 = 0,
    total_supply: StorageMap<AssetId, u64> = StorageMap {},
}

fn foo(recipient: Identity) {
    let recipient = Identity::ContractId(ContractId::zero());
    let asset_id = _mint(storage.total_assets, storage.total_supply, recipient, SubId::zero(), 100);
    assert(balance_of(recipient.as_contract_id(), asset_id), 100);
}