One reason behind this decision, is that there’s actually two opcodes for transferring assets in the FuelVM: TR transfers tokens to a contract (increasing the contract’s balance), and TRO transfers tokens to an address by adding the assets to an output UTXO.
If MINT directly had a “to” address, there would need to be two opcodes (MINT & MINTO). So it’s simpler to just mint directly to the minting contract.
I’ve just stumbled upon the Native Token Example in the Sway docs, which implements the following functions:
impl NativeAssetToken for Contract {
/// <---- snip ----> ///
/// Mint and send this contracts native token to a destination contract.
fn mint_and_send_to_contract(amount: u64, destination: ContractId) {
mint_to_contract(destination, ZERO_B256, amount);
}
/// Mind and send this contracts native token to a destination address.
fn mint_and_send_to_address(amount: u64, recipient: Address) {
mint_to_address(recipient, ZERO_B256, amount);
}
}
This in turn has led me to the mint_to_contract function in the Sway Standard Library.
Thus, it seems to me that the problem of “how to mint and transfer in one go” is effectively solved at a level above the raw FuelVM, i.e., in the Sway Standard Library.