Generic Asset Module

The Generic Asset module provides functionality for handling accounts and asset balances.

Overview

The Generic Asset module provides functions for:

Terminology

Implementations

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.

The Generic Asset module provides two types of AssetCurrency as follows.

Interface

Dispatchable Functions

Public Functions

Usage

The following examples show how to use the Generic Asset Pallet in your custom pallet.

Examples from the FRAME 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 = <::Currency as Currency<::AccountId>>::Balance;

fn charge_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::DispatchResult { // ... T::Currency::withdraw( transactor, amount, WithdrawReason::TransactionPayment.into(), ExistenceRequirement::KeepAlive, )?; // ... Ok(()) }

fn refundfee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::DispatchResult { // ... T::Currency::depositinto_existing(transactor, amount)?; // ... Ok(()) }

```

Genesis config

The Generic Asset Pallet depends on the GenesisConfig.

License: Apache-2.0