pub trait Mutate<AccountId>: Inspect<AccountId> {
fn mint_into(who: &AccountId, amount: Self::Balance) -> DispatchResult;
fn burn_from(
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>;
fn slash(
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError> { ... }
fn teleport(
source: &AccountId,
dest: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError> { ... }
}
Expand description
Trait for providing an ERC-20 style fungible asset.
Required Methods§
sourcefn mint_into(who: &AccountId, amount: Self::Balance) -> DispatchResult
fn mint_into(who: &AccountId, amount: Self::Balance) -> DispatchResult
Increase the balance of who
by exactly amount
, minting new tokens. If that isn’t
possible then an Err
is returned and nothing is changed.
sourcefn burn_from(
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
fn burn_from(
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
Decrease the balance of who
by at least amount
, possibly slightly more in the case of
minimum_balance requirements, burning the tokens. If that isn’t possible then an Err
is
returned and nothing is changed. If successful, the amount of tokens reduced is returned.
Provided Methods§
sourcefn slash(
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
fn slash(
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
Attempt to reduce the balance of who
by as much as possible up to amount
, and possibly
slightly more due to minimum_balance requirements. If no decrease is possible then an Err
is returned and nothing is changed. If successful, the amount of tokens reduced is returned.
The default implementation just uses withdraw
along with reducible_balance
to ensure
that is doesn’t fail.