[][src]Crate srml_balances

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

Public Functions

Usage

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

Examples from the SRML

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

use srml_support::traits::Currency;

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

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

use srml_support::traits::{WithdrawReasons, LockableCurrency};
use primitives::traits::Bounded;
pub trait Trait: system::Trait {
	type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
}

fn update_ledger<T: Trait>(
	controller: &T::AccountId,
	ledger: &StakingLedger<T>
) {
	T::Currency::set_lock(
		STAKING_ID,
		&ledger.stash,
		ledger.total,
		T::BlockNumber::max_value(),
		WithdrawReasons::all()
	);
	// <Ledger<T>>::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

Structs

BalanceLock
CreationFee

The fee required to create an account.

DefaultInstance

Default module instance

ExistentialDeposit

The minimum amount required to keep an account open.

FreeBalance

The 'free' balance of a given account.

GenesisConfig
Instance0

Module instance

Instance1

Module instance

Instance2

Module instance

Instance3

Module instance

Instance4

Module instance

Instance5

Module instance

Instance6

Module instance

Instance7

Module instance

Instance8

Module instance

Instance9

Module instance

Instance10

Module instance

Instance11

Module instance

Instance12

Module instance

Instance13

Module instance

Instance14

Module instance

Instance15

Module instance

Locks

Any liquidity locks on some account balances.

Module
NegativeImbalance

Opaque, move-only struct with private fields that serves as a token denoting that funds have been destroyed without any equal and opposite accounting.

PositiveImbalance

Opaque, move-only struct with private fields that serves as a token denoting that funds have been created without any equal and opposite accounting.

ReservedBalance

The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all.

TotalIssuance

The total units issued in the system.

TransactionBaseFee

The fee to be paid for making a transaction; the base.

TransactionByteFee

The fee to be paid for making a transaction; the per-byte portion.

TransferFee

The fee required to make a transfer.

Vesting

Information regarding the vesting of a given account.

VestingSchedule

Struct to encode the vesting schedule of an individual account.

Enums

Call
RawEvent

Events for this module.

Traits

Instance

Tag a type as an instance of a module.

Subtrait
Trait

Type Definitions

Event

RawEvent specialized for the configuration Trait