Struct pallet_balances::pallet::Pallet[][src]

pub struct Pallet<T, I = ()>(_);
Expand description

The pallet implementing the on-chain logic.

Implementations

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 as transfer, 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.

Set the balances of a given account.

This will alter FreeBalance and ReservedBalance in storage. it will also decrease the total issuance of the system (TotalIssuance). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (frame_system::AccountNonce).

The dispatch origin for this call is root.

  • Independent of the arguments.
  • Contains a limited number of reads and writes.

  • Base Weight:
    • Creating: 27.56 µs
    • Killing: 35.11 µs
  • DB Weight: 1 Read, 1 Write to who

Exactly as transfer, except the origin must be root and the source account may be specified.

  • Same as transfer, but additional read and write because the source account is not assumed to be in the overlay.

Same as the transfer call, but with a check that the transfer will not kill the origin account.

99% of the time you want transfer instead.

  • Cheaper than transfer because account cannot be killed.
  • Base Weight: 51.4 µs
  • DB Weight: 1 Read and 1 Write to dest (sender is in overlay already) #

Transfer the entire transferable balance from the caller account.

NOTE: This function only attempts to transfer transferable balances. This means that any locked, reserved, or existential deposits (when keep_alive is true), will not be transferred by this function. To ensure that this function results in a killed account, you might need to prepare the account by removing any reference counters, storage deposits, etc…

The dispatch origin of this call must be Signed.

  • dest: The recipient of the transfer.
  • keep_alive: A boolean to determine if the transfer_all operation should send all of the funds the account has, causing the sender account to be killed (false), or transfer everything except at least the existential deposit, which will guarantee to keep the sender account alive (true). #
  • O(1). Just like transfer, but reading the user’s transferable balance first. #

The total units issued in the system.

Any liquidity locks on some account balances. NOTE: Should only be accessed when setting, changing and freeing a lock.

Named reserves on some account balances.

Get the free balance of an account.

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.

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.

Get the reserved balance of an account.

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

Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more

Run the benchmarks for this pallet.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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.

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.

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 of who to overflow.

Withdraw some free balance from an account, respecting existence requirements.

Is a no-op if value to be withdrawn is zero.

Force the new free balance of a target account who to some new value balance.

The balance of an account.

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

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

The combined balance of who.

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

The total amount of issuance in the system.

The minimum balance any single account may have. This is equivalent to the Balances module’s ExistentialDeposit. Read more

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

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

The ‘free’ balance of a given account. Read more

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

Transfer some liquid free balance to another staker. Read more

Produce a pair of imbalances that cancel each other out exactly. Read more

Similar to deposit_creating, only accepts a NegativeImbalance and returns nothing on success. Read more

Similar to deposit_creating, only accepts a NegativeImbalance and returns nothing on success. Read more

Similar to withdraw, only accepts a PositiveImbalance and returns nothing on success.

Formats the value using the given formatter. Read more

Returns the current storage version as supported by the pallet.

Returns the on-chain storage version of the pallet as stored in the storage.

The block is being finalized. Implement to have something happen.

This will be run when the block is being finalized (before on_finalize). Implement to have something happen using the remaining weight. Will not fire if the remaining weight is 0. Return the weight used, the hook will subtract it from current weight used and pass the result to the next on_idle hook if it exists. Read more

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

Execute some pre-checks prior to a runtime upgrade. Read more

Execute some post-checks after a runtime upgrade. Read more

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

Run integrity test. Read more

Scalar type for representing balance of an account.

The total amount of issuance in the system.

The minimum balance any single account may have.

Get the balance of who.

Get the maximum amount that who can withdraw/transfer successfully.

Returns true if the balance of who may be increased by amount.

Returns Failed if the balance of who may not be decreased by amount, otherwise the consequence. Read more

Amount of funds held in reserve by who.

Check to see if some amount of funds of who may be placed on hold.

Run integrity test. Read more

The quantity used to denote time; usually just a BlockNumber.

The maximum number of locks a user should have on their account.

Create a new balance lock on account who. Read more

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

Remove an existing lock.

Increase the balance of who by exactly amount, minting new tokens. If that isn’t possible then an Err is returned and nothing is changed. Read more

Decrease the balance of who by at least amount, possibly slightly more in the case of minimum_balance requirements, burning the tokens. If that isn’t possible then an Err is returned and nothing is changed. If successful, the amount of tokens reduced is returned. Read more

Attempt to reduce the balance of who by as much as possible up to amount, and possibly slightly more due to minimum_balance requirements. If no decrease is possible then an Err is returned and nothing is changed. If successful, the amount of tokens reduced is returned. Read more

Transfer funds from one account into another. The default implementation uses mint_into and burn_from and may generate unwanted events. Read more

Hold some funds in an account.

Release up to amount held funds in an account. Read more

Transfer held funds into a destination account. Read more

Move value from the free balance from who to a named reserve balance.

Is a no-op if value to be reserved is zero.

Unreserve some funds, returning any amount that was unable to be unreserved.

Is a no-op if the value to be unreserved is zero.

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.

Move the reserved balance of one account into the balance of another, according to status. If status is Reserved, the balance will be reserved with given id.

Is a no-op if:

  • the value to be moved is zero; or
  • the slashed id equal to beneficiary and the status is Reserved.

An identifier for a reserve. Used for disambiguating different reserves so that they can be individually replaced or removed. Read more

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

Ensure the reserved balance is equal to value. Read more

Unreserve all the named reserved balances, returning unreserved amount. Read more

Slash all the reserved balance, returning the negative imbalance created. Read more

Move all the named reserved balance of one account into the balance of another, according to status. If status is Reserved, the balance will be reserved with given id. Read more

This function is being called after every block import (when fully synced). Read more

The block is being finalized. Implement to have something happen. Read more

Something that should happen at genesis.

The block is being finalized. Implement to have something happen in case there is leftover weight. Check the passed remaining_weight to make sure it is high enough to allow for your pallet’s extra computation. Read more

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

Execute some pre-checks prior to a runtime upgrade. Read more

Execute some post-checks after a runtime upgrade. Read more

Index of the pallet as configured in the runtime.

Name of the pallet as configured in the runtime.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Check if who can reserve value from their free balance.

Always true if value to be reserved is zero.

Move value from the free balance from who to their reserved balance.

Is a no-op if value to be reserved is zero.

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.

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.

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 to beneficiary and the status is Reserved.

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

Transfer funds from one account into another.

Set the balance of who to amount. If this cannot be done for some reason (e.g. because the account cannot be created or an overflow) then an Err is returned. Read more

Set the total issuance to amount.

Reduce the balance of who by amount. If it cannot be reduced by that amount for some reason, return Err and don’t reduce it at all. If Ok, return the imbalance. Read more

Reduce the balance of who by the most that is possible, up to amount. Read more

Increase the balance of who by amount. If it cannot be increased by that amount for some reason, return Err and don’t increase it at all. If Ok, return the imbalance. Read more

Increase the balance of who by the most that is possible, up to amount. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The type for managing what happens when an instance of Credit is dropped without being used. Read more

The type for managing what happens when an instance of Debt is dropped without being used.

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

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

Deducts up to value from the combined balance of who. This function cannot fail. Read more

Mints exactly value into the account of who. Read more

Removes value balance from who account if possible. Read more

Produce a pair of imbalances that cancel each other out exactly. Read more

The balance of who is increased in order to counter credit. If the whole of credit cannot be countered, then nothing is changed and the original credit is returned in an Err. Read more

The balance of who is decreased in order to counter debt. If the whole of debt cannot be countered, then nothing is changed and the original debt is returned in an Err. Read more

Reduce the balance of some funds on hold in an account. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Generate a storage key unique to this runtime upgrade. Read more

Get temporary storage data written by Self::set_temp_storage. Read more

Write some temporary data to a specific storage that can be read (potentially in post-upgrade hook) via Self::get_temp_storage. Read more

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.