Balances Module

The Balances module provides functionality for handling accounts and balances.

Overview

The Balances module provides functions for:

Terminology

Implementations

The Balances module provides implementations for the following traits. If these traits provide the functionality that you need, then you can avoid coupling with the Balances module.

Interface

Dispatchable Functions

Usage

The following examples show how to use the Balances module in your custom module.

Examples from the FRAME

The Contract module uses the Currency trait to handle gas payment, and its types inherit from Currency:

```rust use frame_support::traits::Currency;

pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; pub type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance;

```

The Staking module uses the LockableCurrency trait to lock a stash account's funds:

```rust use framesupport::traits::{WithdrawReasons, LockableCurrency}; use spruntime::traits::Bounded; pub trait Config: frame_system::Config { type Currency: LockableCurrency; }

fn updateledger( controller: &T::AccountId, ledger: &StakingLedger ) { T::Currency::setlock( STAKING_ID, &ledger.stash, ledger.total, WithdrawReasons::all() ); // >::insert(controller, ledger); // Commented out as we don't have access to Staking's storage here. } ```

Genesis config

The Balances module depends on the GenesisConfig.

Assumptions

License: Apache-2.0