The Generic Asset module provides functionality for handling accounts and asset balances.
The Generic Asset module provides functions for:
Imbalance
trait that can be managed within your runtime logic. (If an imbalance is
simply dropped, it should automatically maintain any book-keeping such as total issuance.)The Generic Asset module provides AssetCurrency
, which implements the following traits. If these traits provide
the functionality that you need, you can avoid coupling with the Generic Asset module.
Currency
: Functions for dealing with a fungible assets system.ReservableCurrency
: Functions for dealing with assets that can be reserved from an account.LockableCurrency
: Functions for dealing with accounts that allow liquidity restrictions.Imbalance
: Functions for handling imbalances between total issuance in the system and account balances.
Must be used when a function creates new assets (e.g. a reward) or destroys some assets (e.g. a system fee).The Generic Asset module provides two types of AssetCurrency
as follows.
StakingAssetCurrency
: Currency for staking.SpendingAssetCurrency
: Currency for payments such as transfer fee, gas fee.create
: Create a new kind of asset.transfer
: Transfer some liquid free balance to another account.update_permission
: Updates permission for a given asset_id
and an account. The origin of this call
must have update permissions.mint
: Mint an asset, increases its total issuance. The origin of this call must have mint permissions.burn
: Burn an asset, decreases its total issuance. The origin of this call must have burn permissions.create_reserved
: Create a new kind of reserved asset. The origin of this call must be root.total_balance
: Get an account's total balance of an asset kind.free_balance
: Get an account's free balance of an asset kind.reserved_balance
: Get an account's reserved balance of an asset kind.create_asset
: Creates an asset.make_transfer
: Transfer some liquid free balance from one account to another.
This will not emit the Transferred
event.make_transfer_with_event
: Transfer some liquid free balance from one account to another.
This will emit the Transferred
event.reserve
: Moves an amount from free balance to reserved balance.unreserve
: Move up to an amount from reserved balance to free balance. This function cannot fail.mint_free
: Mint to an account's free balance.burn_free
: Burn an account's free balance.slash
: Deduct up to an amount from the combined balance of who
, preferring to deduct from the
free balance. This function cannot fail.slash_reserved
: Deduct up to an amount from reserved balance of an account. This function cannot fail.repatriate_reserved
: Move up to an amount from reserved balance of an account to free balance of another
account.check_permission
: Check permission to perform burn, mint or update.ensure_can_withdraw
: Check if the account is able to make a withdrawal of the given amount
for the given reason.The following examples show how to use the Generic Asset Pallet in your custom pallet.
The Fees Pallet uses the Currency
trait to handle fee charge/refund, and its types inherit from Currency
:
```rust
use frame_support::{
dispatch,
traits::{Currency, ExistenceRequirement, WithdrawReason},
};
type AssetOf
fn charge_fee
fn refundfee
```
The Generic Asset Pallet depends on the GenesisConfig
.
License: Apache-2.0