Trait frame_support::traits::tokens::fungibles::Mutate[][src]

pub trait Mutate<AccountId>: Inspect<AccountId> {
    fn mint_into(
        asset: Self::AssetId,
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
fn burn_from(
        asset: Self::AssetId,
        who: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError>; fn slash(
        asset: Self::AssetId,
        who: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError> { ... }
fn teleport(
        asset: Self::AssetId,
        source: &AccountId,
        dest: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError> { ... } }
Expand description

Trait for providing a set of named fungible assets which can be created and destroyed.

Required methods

Attempt to increase the asset balance of who by amount.

If not possible then don’t do anything. Possible reasons for failure include:

  • Minimum balance not met.
  • Account cannot be created (e.g. because there is no provider reference and/or the asset isn’t considered worth anything).

Since this is an operation which should be possible to take alone, if successful it will increase the overall supply of the underlying token.

Attempt to reduce the asset balance of who by amount.

If not possible then don’t do anything. Possible reasons for failure include:

  • Less funds in the account than amount
  • Liquidity requirements (locks, reservations) prevent the funds from being removed
  • Operation would require destroying the account and it is required to stay alive (e.g. because it’s providing a needed provider reference).

Since this is an operation which should be possible to take alone, if successful it will reduce the overall supply of the underlying token.

Due to minimum balance requirements, it’s possible that the amount withdrawn could be up to Self::minimum_balance() - 1 more than the amount. The total amount withdrawn is returned in an Ok result. This may be safely ignored if you don’t mind the overall supply reducing.

Provided methods

Attempt to reduce the asset 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.

Transfer funds from one account into another. The default implementation uses mint_into and burn_from and may generate unwanted events.

Implementors