Crates.io | tetched-noble-balances |
lib.rs | tetched-noble-balances |
version | 0.0.0 |
source | src |
created_at | 2021-05-25 23:38:04.70175 |
updated_at | 2021-05-25 23:38:04.70175 |
description | The Balances module provides functionality for handling accounts and balances for Tetched Nodes |
homepage | https://github.com/tetched/tetched-node |
repository | https://github.com/tetched/tetched-node.git |
max_upload_size | |
id | 402082 |
size | 6,886 |
The Balances module provides functionality for handling accounts and balances. - balances::Trait
-
Call
- Module
The Balances module provides functions for: - Getting and setting free balances. - Retrieving total, reserved and unreserved balances. - Repatriating a reserved balance to a beneficiary account that exists. - Transferring a balance between accounts (when not reserved). - Slashing an account balance. - Account creation and removal. - Managing total issuance. - Setting and managing locks.
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.) - Lock: A freeze on a specified amount of an account's free balance until a specified block number. Multiple locks always operate over the same
funds, so they "overlay" rather than "stack".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. -
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 funds (e.g. a reward) or destroys some funds (e.g. a system fee). -
IsDeadAccount
: Determiner to say whether a given account is unused.
transfer
- Transfer some liquid free balance to another account. - set_balance
- Set the balances of a given account. The origin of this call must be root.The following examples show how to use the Balances module in your custom module.
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<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; pub type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
The Staking module uses the LockableCurrency
trait to lock a stash account's funds: ```rust use
frame_support::traits::{WithdrawReasons, LockableCurrency}; use sp_runtime::traits::Bounded; pub trait Config: frame_system::Config {
type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
}
fn update_ledger<T: Config>( controller: &T::AccountId, ledger: &StakingLedger
## Genesis config
The Balances module depends on the [`GenesisConfig`](https://docs.rs/pallet-balances/latest/pallet_balances/struct.GenesisConfig.html).
## Assumptions
* Total issued balanced of all accounts should be less than `Config::Balance::max_value()`. License: Apache-2.0