pub trait BasicCurrency<AccountId> {
    type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + MaxEncodedLen;

    fn minimum_balance() -> Self::Balance;
    fn total_issuance() -> Self::Balance;
    fn total_balance(who: &AccountId) -> Self::Balance;
    fn free_balance(who: &AccountId) -> Self::Balance;
    fn ensure_can_withdraw(
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult; fn transfer(
        from: &AccountId,
        to: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult; fn deposit(who: &AccountId, amount: Self::Balance) -> DispatchResult; fn withdraw(who: &AccountId, amount: Self::Balance) -> DispatchResult; fn can_slash(who: &AccountId, value: Self::Balance) -> bool; fn slash(who: &AccountId, amount: Self::Balance) -> Self::Balance; }
Expand description

Abstraction over a fungible (single) currency system.

Required Associated Types§

Required Methods§

Existential deposit.

The total amount of issuance.

The combined balance of who.

The free balance of who.

A dry-run of withdraw. Returns Ok iff the account is able to make a withdrawal of the given amount.

Transfer some amount from one account to another.

Add amount to the balance of who and increase total issuance.

Remove amount from the balance of who and reduce total issuance.

Same result as slash(who, value) (but without the side-effects) assuming there are no balance changes in the meantime and only the reserved balance is not taken into account.

Deduct the balance of who by up to amount.

As much funds up to amount will be deducted as possible. If this is less than amount, then a non-zero excess value will be returned.

Implementors§