pub fn transfer(to: Identity, asset_id: AssetId, amount: u64) Expand description
Transfer amount coins of the type asset_id and send them to to.
Additional Information
If the to Identity is a contract this may transfer coins to the contract even with no way to retrieve them (i.e. no withdrawal functionality on receiving contract), possibly leading to the PERMANENT LOSS OF COINS if not used with care.
Arguments
to: [Identity] - The recipient identity.asset_id: [AssetId] - The asset to transfer.amount: [u64] - The amount of coins to transfer.
Reverts
- When
amountis greater than the contract balance forasset_id. - When
amountis equal to zero. - When there are no free variable outputs when transferring to an
Address.
Examples
use std::asset::transfer;
fn foo() {
let to_address = Identity::Address(Address::zero());
let to_contract_id = Identity::ContractId(ContractId::zero());
transfer(to_address, AssetId::base(), 500);
transfer(to_contract_id, AssetId::base(), 500);
}