Struct pallet_balances::pallet::Pallet
source · [−]pub struct Pallet<T, I = ()>(_);
Implementations
sourceimpl<T: Config<I>, I: 'static> Pallet<T, I>
impl<T: Config<I>, I: 'static> Pallet<T, I>
sourcepub fn transfer(
origin: OriginFor<T>,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance
) -> DispatchResultWithPostInfo
pub fn transfer(
origin: OriginFor<T>,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance
) -> DispatchResultWithPostInfo
Transfer some liquid free balance to another account.
transfer
will set the FreeBalance
of the sender and receiver.
It will decrease the total issuance of the system by the TransferFee
.
If the sender’s account is below the existential deposit as a result
of the transfer, the account will be reaped.
The dispatch origin for this call must be Signed
by the transactor.
- Dependent on arguments but not critical, given proper implementations for input config types. See related functions below.
- It contains a limited number of reads and writes internally and no complex computation.
Related functions:
ensure_can_withdraw
is always called internally but has a bounded complexity.- Transferring balances to accounts that did not exist before will cause
T::OnNewAccount::on_new_account
to be called. - Removing enough funds from an account will trigger
T::DustRemoval::on_unbalanced
. transfer_keep_alive
works the same way astransfer
, but has an additional check that the transfer will not kill the origin account.
- Base Weight: 73.64 µs, worst case scenario (account created, account removed)
- DB Weight: 1 Read and 1 Write to destination account
- Origin account is already in memory, so no DB operations for them.
sourcepub fn force_transfer(
origin: OriginFor<T>,
source: <T::Lookup as StaticLookup>::Source,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance
) -> DispatchResultWithPostInfo
pub fn force_transfer(
origin: OriginFor<T>,
source: <T::Lookup as StaticLookup>::Source,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance
) -> DispatchResultWithPostInfo
sourcepub fn transfer_keep_alive(
origin: OriginFor<T>,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance
) -> DispatchResultWithPostInfo
pub fn transfer_keep_alive(
origin: OriginFor<T>,
dest: <T::Lookup as StaticLookup>::Source,
value: T::Balance
) -> DispatchResultWithPostInfo
sourceimpl<T: Config<I>, I: 'static> Pallet<T, I>
impl<T: Config<I>, I: 'static> Pallet<T, I>
sourcepub fn total_issuance() -> T::Balance
pub fn total_issuance() -> T::Balance
The total units issued in the system.
sourceimpl<T: Config<I>, I: 'static> Pallet<T, I>
impl<T: Config<I>, I: 'static> Pallet<T, I>
sourcepub fn locks<KArg>(k: KArg) -> Vec<BalanceLock<T::Balance>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
KArg: EncodeLike<T::AccountId>,
pub fn locks<KArg>(k: KArg) -> Vec<BalanceLock<T::Balance>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
KArg: EncodeLike<T::AccountId>,
A: Allocator,
Any liquidity locks on some account balances. NOTE: Should only be accessed when setting, changing and freeing a lock.
sourceimpl<T: Config<I>, I: 'static> Pallet<T, I>
impl<T: Config<I>, I: 'static> Pallet<T, I>
sourcepub fn free_balance(who: impl Borrow<T::AccountId>) -> T::Balance
pub fn free_balance(who: impl Borrow<T::AccountId>) -> T::Balance
Get the free balance of an account.
sourcepub fn usable_balance(who: impl Borrow<T::AccountId>) -> T::Balance
pub fn usable_balance(who: impl Borrow<T::AccountId>) -> T::Balance
Get the balance of an account that can be used for transfers, reservations, or any other
non-locking, non-transaction-fee activity. Will be at most free_balance
.
sourcepub fn usable_balance_for_fees(who: impl Borrow<T::AccountId>) -> T::Balance
pub fn usable_balance_for_fees(who: impl Borrow<T::AccountId>) -> T::Balance
Get the balance of an account that can be used for paying transaction fees (not tipping,
or any other kind of fees, though). Will be at most free_balance
.
sourcepub fn reserved_balance(who: impl Borrow<T::AccountId>) -> T::Balance
pub fn reserved_balance(who: impl Borrow<T::AccountId>) -> T::Balance
Get the reserved balance of an account.
sourcepub fn mutate_account<R>(
who: &T::AccountId,
f: impl FnOnce(&mut AccountData<T::Balance>) -> R
) -> Result<R, StoredMapError>
pub fn mutate_account<R>(
who: &T::AccountId,
f: impl FnOnce(&mut AccountData<T::Balance>) -> R
) -> Result<R, StoredMapError>
Mutate an account to some new value, or delete it entirely with None
. Will enforce
ExistentialDeposit
law, annulling the account as needed.
NOTE: Doesn’t do any preparatory work for creating a new account, so should only be used when it is known that the account already exists.
NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that the caller will do this.
Trait Implementations
sourceimpl<T: Config<I>, I: 'static> Currency<<T as Config>::AccountId> for Pallet<T, I> where
T::Balance: MaybeSerializeDeserialize + Debug,
impl<T: Config<I>, I: 'static> Currency<<T as Config>::AccountId> for Pallet<T, I> where
T::Balance: MaybeSerializeDeserialize + Debug,
sourcefn slash(
who: &T::AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
fn slash(
who: &T::AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
Slash a target account who
, returning the negative imbalance created and any left over
amount that could not be slashed.
Is a no-op if value
to be slashed is zero or the account does not exist.
NOTE: slash()
prefers free balance, but assumes that reserve balance can be drawn
from in extreme circumstances. can_slash()
should be used prior to slash()
to avoid having
to draw from reserved funds, however we err on the side of punishment if things are inconsistent
or can_slash
wasn’t used appropriately.
sourcefn deposit_into_existing(
who: &T::AccountId,
value: Self::Balance
) -> Result<Self::PositiveImbalance, DispatchError>
fn deposit_into_existing(
who: &T::AccountId,
value: Self::Balance
) -> Result<Self::PositiveImbalance, DispatchError>
Deposit some value
into the free balance of an existing target account who
.
Is a no-op if the value
to be deposited is zero.
sourcefn deposit_creating(
who: &T::AccountId,
value: Self::Balance
) -> Self::PositiveImbalance
fn deposit_creating(
who: &T::AccountId,
value: Self::Balance
) -> Self::PositiveImbalance
Deposit some value
into the free balance of who
, possibly creating a new account.
This function is a no-op if:
- the
value
to be deposited is zero; or - the
value
to be deposited is less than the required ED and the account does not yet exist; or - the deposit would necessitate the account to exist and there are no provider references; or
value
is so large it would cause the balance ofwho
to overflow.
sourcefn withdraw(
who: &T::AccountId,
value: Self::Balance,
reasons: WithdrawReasons,
liveness: ExistenceRequirement
) -> Result<Self::NegativeImbalance, DispatchError>
fn withdraw(
who: &T::AccountId,
value: Self::Balance,
reasons: WithdrawReasons,
liveness: ExistenceRequirement
) -> Result<Self::NegativeImbalance, DispatchError>
Withdraw some free balance from an account, respecting existence requirements.
Is a no-op if value to be withdrawn is zero.
sourcefn make_free_balance_be(
who: &T::AccountId,
value: Self::Balance
) -> SignedImbalance<Self::Balance, Self::PositiveImbalance>
fn make_free_balance_be(
who: &T::AccountId,
value: Self::Balance
) -> SignedImbalance<Self::Balance, Self::PositiveImbalance>
Force the new free balance of a target account who
to some new value balance
.
type PositiveImbalance = PositiveImbalance<T, I>
type PositiveImbalance = PositiveImbalance<T, I>
The opaque token type for an imbalance. This is returned by unbalanced operations and must be dealt with. It may be dropped but cannot be cloned. Read more
type NegativeImbalance = NegativeImbalance<T, I>
type NegativeImbalance = NegativeImbalance<T, I>
The opaque token type for an imbalance. This is returned by unbalanced operations and must be dealt with. It may be dropped but cannot be cloned. Read more
sourcefn total_balance(who: &T::AccountId) -> Self::Balance
fn total_balance(who: &T::AccountId) -> Self::Balance
The combined balance of who
.
sourcefn can_slash(who: &T::AccountId, value: Self::Balance) -> bool
fn can_slash(who: &T::AccountId, value: Self::Balance) -> bool
Same result as slash(who, value)
(but without the side-effects) assuming there are no
balance changes in the meantime and only the reserved balance is not taken into account. Read more
sourcefn total_issuance() -> Self::Balance
fn total_issuance() -> Self::Balance
The total amount of issuance in the system.
sourcefn minimum_balance() -> Self::Balance
fn minimum_balance() -> Self::Balance
The minimum balance any single account may have. This is equivalent to the Balances
module’s
ExistentialDeposit
. Read more
sourcefn burn(amount: Self::Balance) -> Self::PositiveImbalance
fn burn(amount: Self::Balance) -> Self::PositiveImbalance
Reduce the total issuance by amount
and return the according imbalance. The imbalance will
typically be used to reduce an account by the same amount with e.g. settle
. Read more
sourcefn issue(amount: Self::Balance) -> Self::NegativeImbalance
fn issue(amount: Self::Balance) -> Self::NegativeImbalance
Increase the total issuance by amount
and return the according imbalance. The imbalance
will typically be used to increase an account by the same amount with e.g.
resolve_into_existing
or resolve_creating
. Read more
sourcefn free_balance(who: &T::AccountId) -> Self::Balance
fn free_balance(who: &T::AccountId) -> Self::Balance
The ‘free’ balance of a given account. Read more
sourcefn ensure_can_withdraw(
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons,
new_balance: T::Balance
) -> DispatchResult
fn ensure_can_withdraw(
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons,
new_balance: T::Balance
) -> DispatchResult
Returns Ok
iff the account is able to make a withdrawal of the given amount
for the given reason. Basically, it’s just a dry-run of withdraw
. Read more
sourcefn transfer(
transactor: &T::AccountId,
dest: &T::AccountId,
value: Self::Balance,
existence_requirement: ExistenceRequirement
) -> DispatchResult
fn transfer(
transactor: &T::AccountId,
dest: &T::AccountId,
value: Self::Balance,
existence_requirement: ExistenceRequirement
) -> DispatchResult
Transfer some liquid free balance to another staker. Read more
sourcefn pair(
amount: Self::Balance
) -> (Self::PositiveImbalance, Self::NegativeImbalance)
fn pair(
amount: Self::Balance
) -> (Self::PositiveImbalance, Self::NegativeImbalance)
Produce a pair of imbalances that cancel each other out exactly. Read more
sourcefn resolve_into_existing(
who: &AccountId,
value: Self::NegativeImbalance
) -> Result<(), Self::NegativeImbalance>
fn resolve_into_existing(
who: &AccountId,
value: Self::NegativeImbalance
) -> Result<(), Self::NegativeImbalance>
Similar to deposit_creating, only accepts a NegativeImbalance
and returns nothing on
success. Read more
sourcefn resolve_creating(who: &AccountId, value: Self::NegativeImbalance)
fn resolve_creating(who: &AccountId, value: Self::NegativeImbalance)
Similar to deposit_creating, only accepts a NegativeImbalance
and returns nothing on
success. Read more
sourcefn settle(
who: &AccountId,
value: Self::PositiveImbalance,
reasons: WithdrawReasons,
liveness: ExistenceRequirement
) -> Result<(), Self::PositiveImbalance>
fn settle(
who: &AccountId,
value: Self::PositiveImbalance,
reasons: WithdrawReasons,
liveness: ExistenceRequirement
) -> Result<(), Self::PositiveImbalance>
Similar to withdraw, only accepts a PositiveImbalance
and returns nothing on success.
sourceimpl<T: Config<I>, I: 'static> GetPalletVersion for Pallet<T, I>
impl<T: Config<I>, I: 'static> GetPalletVersion for Pallet<T, I>
sourcefn current_version() -> PalletVersion
fn current_version() -> PalletVersion
Returns the current version of the pallet.
sourcefn storage_version() -> Option<PalletVersion>
fn storage_version() -> Option<PalletVersion>
Returns the version of the pallet that is stored in storage. Read more
sourceimpl<T: Config<I>, I: 'static> Hooks<<T as Config>::BlockNumber> for Pallet<T, I>
impl<T: Config<I>, I: 'static> Hooks<<T as Config>::BlockNumber> for Pallet<T, I>
sourcefn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
The block is being finalized. Implement to have something happen.
sourcefn on_initialize(_n: BlockNumber) -> u64
fn on_initialize(_n: BlockNumber) -> u64
The block is being initialized. Implement to have something happen. Read more
sourcefn on_runtime_upgrade() -> u64
fn on_runtime_upgrade() -> u64
Perform a module upgrade. Read more
sourcefn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more
sourcefn integrity_test()
fn integrity_test()
Run integrity test. Read more
sourceimpl<T: Config<I>, I: 'static> IntegrityTest for Pallet<T, I>
impl<T: Config<I>, I: 'static> IntegrityTest for Pallet<T, I>
sourcefn integrity_test()
fn integrity_test()
Run integrity test. Read more
sourceimpl<T: Config<I>, I: 'static> LockableCurrency<<T as Config>::AccountId> for Pallet<T, I> where
T::Balance: MaybeSerializeDeserialize + Debug,
impl<T: Config<I>, I: 'static> LockableCurrency<<T as Config>::AccountId> for Pallet<T, I> where
T::Balance: MaybeSerializeDeserialize + Debug,
type Moment = T::BlockNumber
type Moment = T::BlockNumber
The quantity used to denote time; usually just a BlockNumber
.
sourcefn set_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons
)
fn set_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons
)
Create a new balance lock on account who
. Read more
sourcefn extend_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons
)
fn extend_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons
)
Changes a balance lock (selected by id
) so that it becomes less liquid in all
parameters or creates a new one if it does not exist. Read more
sourcefn remove_lock(id: LockIdentifier, who: &T::AccountId)
fn remove_lock(id: LockIdentifier, who: &T::AccountId)
Remove an existing lock.
sourceimpl<T: Config<I>, I: 'static> ModuleErrorMetadata for Pallet<T, I>
impl<T: Config<I>, I: 'static> ModuleErrorMetadata for Pallet<T, I>
sourceimpl<T: Config<I>, I: 'static> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T, I>
impl<T: Config<I>, I: 'static> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T, I>
sourcefn offchain_worker(n: <T as Config>::BlockNumber)
fn offchain_worker(n: <T as Config>::BlockNumber)
This function is being called after every block import (when fully synced). Read more
sourceimpl<T: Config<I>, I: 'static> OnFinalize<<T as Config>::BlockNumber> for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnFinalize<<T as Config>::BlockNumber> for Pallet<T, I>
sourcefn on_finalize(n: <T as Config>::BlockNumber)
fn on_finalize(n: <T as Config>::BlockNumber)
The block is being finalized. Implement to have something happen. Read more
sourceimpl<T: Config<I>, I: 'static> OnGenesis for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnGenesis for Pallet<T, I>
sourcefn on_genesis()
fn on_genesis()
Something that should happen at genesis.
sourceimpl<T: Config<I>, I: 'static> OnInitialize<<T as Config>::BlockNumber> for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnInitialize<<T as Config>::BlockNumber> for Pallet<T, I>
sourcefn on_initialize(n: <T as Config>::BlockNumber) -> Weight
fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
The block is being initialized. Implement to have something happen. Read more
sourceimpl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Pallet<T, I>
sourcefn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
sourceimpl<T: Config<I>, I: 'static> ReservableCurrency<<T as Config>::AccountId> for Pallet<T, I> where
T::Balance: MaybeSerializeDeserialize + Debug,
impl<T: Config<I>, I: 'static> ReservableCurrency<<T as Config>::AccountId> for Pallet<T, I> where
T::Balance: MaybeSerializeDeserialize + Debug,
sourcefn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool
fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool
Check if who
can reserve value
from their free balance.
Always true
if value to be reserved is zero.
sourcefn reserve(who: &T::AccountId, value: Self::Balance) -> DispatchResult
fn reserve(who: &T::AccountId, value: Self::Balance) -> DispatchResult
Move value
from the free balance from who
to their reserved balance.
Is a no-op if value to be reserved is zero.
sourcefn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance
fn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance
Unreserve some funds, returning any amount that was unable to be unreserved.
Is a no-op if the value to be unreserved is zero or the account does not exist.
sourcefn slash_reserved(
who: &T::AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
fn slash_reserved(
who: &T::AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
Slash from reserved balance, returning the negative imbalance created, and any amount that was unable to be slashed.
Is a no-op if the value to be slashed is zero or the account does not exist.
sourcefn repatriate_reserved(
slashed: &T::AccountId,
beneficiary: &T::AccountId,
value: Self::Balance,
status: Status
) -> Result<Self::Balance, DispatchError>
fn repatriate_reserved(
slashed: &T::AccountId,
beneficiary: &T::AccountId,
value: Self::Balance,
status: Status
) -> Result<Self::Balance, DispatchError>
Move the reserved balance of one account into the balance of another, according to status
.
Is a no-op if:
- the value to be moved is zero; or
- the
slashed
id equal tobeneficiary
and thestatus
isReserved
.
sourcefn reserved_balance(who: &T::AccountId) -> Self::Balance
fn reserved_balance(who: &T::AccountId) -> Self::Balance
The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. Read more
impl<T, I> Eq for Pallet<T, I>
Auto Trait Implementations
impl<T, I> RefUnwindSafe for Pallet<T, I> where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, I> Send for Pallet<T, I> where
I: Send,
T: Send,
impl<T, I> Sync for Pallet<T, I> where
I: Sync,
T: Sync,
impl<T, I> Unpin for Pallet<T, I> where
I: Unpin,
T: Unpin,
impl<T, I> UnwindSafe for Pallet<T, I> where
I: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.