Balances¶
Calls¶
force_adjust_total_issuance¶
Adjust the total issuance in a saturating way.
Can only be called by root and always needs a positive delta
.
# Example
Attributes¶
Name | Type |
---|---|
direction | AdjustmentDirection |
delta | T::Balance |
Python¶
call = substrate.compose_call(
'Balances', 'force_adjust_total_issuance', {
'delta': 'u64',
'direction': (
'Increase',
'Decrease',
),
}
)
force_set_balance¶
Set the regular balance of a given account.
The dispatch origin for this call is root
.
Attributes¶
Name | Type |
---|---|
who | AccountIdLookupOf<T> |
new_free | T::Balance |
Python¶
call = substrate.compose_call(
'Balances', 'force_set_balance', {
'new_free': 'u64',
'who': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
}
)
force_transfer¶
Exactly as transfer_allow_death
, except the origin must be root and the source account
may be specified.
Attributes¶
Name | Type |
---|---|
source | AccountIdLookupOf<T> |
dest | AccountIdLookupOf<T> |
value | T::Balance |
Python¶
call = substrate.compose_call(
'Balances', 'force_transfer', {
'dest': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
'source': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
'value': 'u64',
}
)
force_unreserve¶
Unreserve some balance from a user by force.
Can only be called by ROOT.
Attributes¶
Name | Type |
---|---|
who | AccountIdLookupOf<T> |
amount | T::Balance |
Python¶
call = substrate.compose_call(
'Balances', 'force_unreserve', {
'amount': 'u64',
'who': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
}
)
transfer_all¶
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 thetransfer_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).
Attributes¶
Name | Type |
---|---|
dest | AccountIdLookupOf<T> |
keep_alive | bool |
Python¶
call = substrate.compose_call(
'Balances', 'transfer_all', {
'dest': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
'keep_alive': 'bool',
}
)
transfer_allow_death¶
Transfer some liquid free balance to another account.
transfer_allow_death
will set the FreeBalance
of the sender and receiver.
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.
Attributes¶
Name | Type |
---|---|
dest | AccountIdLookupOf<T> |
value | T::Balance |
Python¶
call = substrate.compose_call(
'Balances', 'transfer_allow_death', {
'dest': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
'value': 'u64',
}
)
transfer_keep_alive¶
Same as the [transfer_allow_death
] call, but with a check that the transfer will not
kill the origin account.
99% of the time you want [transfer_allow_death
] instead.
Attributes¶
Name | Type |
---|---|
dest | AccountIdLookupOf<T> |
value | T::Balance |
Python¶
call = substrate.compose_call(
'Balances', 'transfer_keep_alive', {
'dest': {
'Address20': '[u8; 20]',
'Address32': '[u8; 32]',
'Id': 'AccountId',
'Index': (),
'Raw': 'Bytes',
},
'value': 'u64',
}
)
upgrade_accounts¶
Upgrade a specified account.
origin
: Must beSigned
.who
: The account to be upgraded.
This will waive the transaction fee if at least all but 10% of the accounts needed to be upgraded. (We let some not have to be upgraded just in order to allow for the possibility of churn).
Attributes¶
Name | Type |
---|---|
who | Vec<T::AccountId> |
Python¶
call = substrate.compose_call(
'Balances', 'upgrade_accounts', {'who': ['AccountId']}
)
Events¶
BalanceSet¶
A balance was set by root.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
free | T::Balance |
u64 |
Burned¶
Some amount was burned from an account.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Deposit¶
Some amount was deposited (e.g. for transaction fees).
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
DustLost¶
An account was removed whose balance was non-zero but below ExistentialDeposit, resulting in an outright loss.
Attributes¶
Name | Type | Composition |
---|---|---|
account | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Endowed¶
An account was created with some free balance.
Attributes¶
Name | Type | Composition |
---|---|---|
account | T::AccountId |
AccountId |
free_balance | T::Balance |
u64 |
Frozen¶
Some balance was frozen.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Issued¶
Total issuance was increased by amount
, creating a credit to be balanced.
Attributes¶
Name | Type | Composition |
---|---|---|
amount | T::Balance |
u64 |
Locked¶
Some balance was locked.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Minted¶
Some amount was minted into an account.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Rescinded¶
Total issuance was decreased by amount
, creating a debt to be balanced.
Attributes¶
Name | Type | Composition |
---|---|---|
amount | T::Balance |
u64 |
ReserveRepatriated¶
Some balance was moved from the reserve of the first account to the second account. Final argument indicates the destination balance type.
Attributes¶
Name | Type | Composition |
---|---|---|
from | T::AccountId |
AccountId |
to | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
destination_status | Status |
('Free', 'Reserved') |
Reserved¶
Some balance was reserved (moved from free to reserved).
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Restored¶
Some amount was restored into an account.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Slashed¶
Some amount was removed from the account (e.g. for misbehavior).
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Suspended¶
Some amount was suspended from an account (it can be restored later).
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Thawed¶
Some balance was thawed.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
TotalIssuanceForced¶
The TotalIssuance
was forcefully changed.
Attributes¶
Name | Type | Composition |
---|---|---|
old | T::Balance |
u64 |
new | T::Balance |
u64 |
Transfer¶
Transfer succeeded.
Attributes¶
Name | Type | Composition |
---|---|---|
from | T::AccountId |
AccountId |
to | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Unlocked¶
Some balance was unlocked.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Unreserved¶
Some balance was unreserved (moved from reserved to free).
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Upgraded¶
An account was upgraded.
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
Withdraw¶
Some amount was withdrawn from the account (e.g. for transaction fees).
Attributes¶
Name | Type | Composition |
---|---|---|
who | T::AccountId |
AccountId |
amount | T::Balance |
u64 |
Storage functions¶
Account¶
The Balances pallet example of storing the balance of an account.
# Example
nocompile
impl pallet_balances::Config for Runtime {
type AccountStore = StorageMapShim<Self::Account<Runtime>, frame_system::Provider<Runtime>, AccountId, Self::AccountData<Balance>>
}
You can also store the balance of an account in the System
pallet.
# Example
nocompile
impl pallet_balances::Config for Runtime {
type AccountStore = System
}
But this comes with tradeoffs, storing account balances in the system pallet stores
frame_system
data alongside the account data contrary to storing account balances in the
Balances
pallet, which uses a StorageMap
to store balances data only.
NOTE: This is only used in the case that this pallet is used to store balances.
Python¶
result = substrate.query(
'Balances', 'Account', ['AccountId']
)
Return value¶
{'flags': 'u128', 'free': 'u64', 'frozen': 'u64', 'reserved': 'u64'}
Freezes¶
Freeze locks on account balances.
Python¶
result = substrate.query(
'Balances', 'Freezes', ['AccountId']
)
Return value¶
[{'amount': 'u64', 'id': ()}]
Holds¶
Holds on account balances.
Python¶
result = substrate.query(
'Balances', 'Holds', ['AccountId']
)
Return value¶
[
{
'amount': 'u64',
'id': {
None: None,
'Preimage': ('Preimage', ),
'Registry': ('RegistryIdentity', ),
'SafeMode': ('EnterOrExtend', ),
},
},
]
InactiveIssuance¶
The total units of outstanding deactivated balance in the system.
Python¶
result = substrate.query(
'Balances', 'InactiveIssuance', []
)
Return value¶
'u64'
Locks¶
Any liquidity locks on some account balances. NOTE: Should only be accessed when setting, changing and freeing a lock.
Use of locks is deprecated in favour of freezes. See https://github.com/paritytech/substrate/pull/12951/
Python¶
result = substrate.query(
'Balances', 'Locks', ['AccountId']
)
Return value¶
[{'amount': 'u64', 'id': '[u8; 8]', 'reasons': ('Fee', 'Misc', 'All')}]
Reserves¶
Named reserves on some account balances.
Use of reserves is deprecated in favour of holds. See https://github.com/paritytech/substrate/pull/12951/
Python¶
result = substrate.query(
'Balances', 'Reserves', ['AccountId']
)
Return value¶
[{'amount': 'u64', 'id': '[u8; 8]'}]
TotalIssuance¶
The total units issued in the system.
Python¶
result = substrate.query(
'Balances', 'TotalIssuance', []
)
Return value¶
'u64'
Constants¶
ExistentialDeposit¶
The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO!
If you really need it to be zero, you can enable the feature insecure_zero_ed
for
this pallet. However, you do so at your own risk: this will open up a major DoS vector.
In case you have multiple sources of provider references, you may also get unexpected
behaviour if you set this to zero.
Bottom line: Do yourself a favour and make it at least one!
Value¶
500
Python¶
constant = substrate.get_constant('Balances', 'ExistentialDeposit')
MaxFreezes¶
The maximum number of individual freeze locks that can exist on an account at any time.
Value¶
50
Python¶
constant = substrate.get_constant('Balances', 'MaxFreezes')
MaxLocks¶
The maximum number of locks that should exist on an account. Not strictly enforced, but used for weight estimation.
Use of locks is deprecated in favour of freezes. See https://github.com/paritytech/substrate/pull/12951/
Value¶
50
Python¶
constant = substrate.get_constant('Balances', 'MaxLocks')
MaxReserves¶
The maximum number of named reserves that can exist on an account.
Use of reserves is deprecated in favour of holds. See https://github.com/paritytech/substrate/pull/12951/
Value¶
50
Python¶
constant = substrate.get_constant('Balances', 'MaxReserves')
Errors¶
DeadAccount¶
Beneficiary account must pre-exist.
DeltaZero¶
The delta cannot be zero.
ExistentialDeposit¶
Value too low to create account due to existential deposit.
ExistingVestingSchedule¶
A vesting schedule already exists for this account.
Expendability¶
Transfer/payment would kill account.
InsufficientBalance¶
Balance too low to send value.
IssuanceDeactivated¶
The issuance cannot be modified since it is already deactivated.
LiquidityRestrictions¶
Account liquidity restrictions prevent withdrawal.
TooManyFreezes¶
Number of freezes exceed MaxFreezes
.
TooManyHolds¶
Number of holds exceed VariantCountOf<T::RuntimeHoldReason>
.
TooManyReserves¶
Number of named reserves exceed MaxReserves
.
VestingBalance¶
Vesting balance too high to send value.