Skip to main content
16 votes
Accepted

When should I use Balances Pallet and when should I use Assets Pallet?

The balances pallet is designed to be used as the blockchain's underlying currency. It is extremely optimized for balance movements and transfers, which ensures that the fees that users pay to ...
Bruno's user avatar
  • 8,315
13 votes
Accepted

Can you use floating point numbers or math in the Runtime?

You cannot use floating point math inside of the runtime. Floating point numbers can lead to non-determinism in computer systems, and that would be exceptionally bad for blockchains since all of them ...
Shawn Tabrizi's user avatar
  • 16.1k
13 votes

What is the difference between Free Balance, Reserved Balance, Locked Balance, Vesting Balance, etc...?

The Balances Pallet is a comprehensive on chain currency which has the flexibility to provide a number of different features. Within the storage of the Balances Pallet, there are only two balances ...
Shawn Tabrizi's user avatar
  • 16.1k
11 votes

How to manage native tokens in Substrate?

For a native token on a Substrate chain you should use the Balances Pallet, not the Assets Pallet. The balances pallet is specially optimized to minimize its computational and storage footprint. This ...
Shawn Tabrizi's user avatar
  • 16.1k
10 votes
Accepted

How do I change my token symbol on substrate-node-template?

One way you can change your token symbol is in the chain_spec.rs file, you can add something like this: let mut properties = Properties::new(); properties.insert("tokenSymbol".into(), "...
Bruno's user avatar
  • 8,315
9 votes

How to pay transaction fees using the custom token created by using pallet_assets?

In order to do this you will need in your runtime the pallet_asset_tx_payment pallet. Here's an example of the configuration. (the pallet would need to be added into the construct_runtime! etc. See ...
Squirrel's user avatar
  • 3,849
9 votes
Accepted

How are the costs of XCM messages designed?

Since XCM is configurable, this can depend from chain to chain. However, most(if not all) Dotsama chains adopt the same approach. We rely on parity's implementation of XcmExecutor (here) and various ...
Dinonard's user avatar
  • 587
8 votes

How to accurately add extrinsic balance transfer values

I'm assuming the above are hex strings? In that case you would need to convert and add them. import { hexToBn } from '@polkadot/util'; // convert and add const total = hexToBn('...
Jaco's user avatar
  • 5,865
7 votes

What criteria do blockchains consider when deciding on Existential Deposit?

On Polkadot/Kusama the ED has been reduced in the past via democracy. Basically this was driven by the increase in price, i.e. what made sense at chain launch didn't make sense anymore. At the end of ...
RosaryBeads's user avatar
7 votes
Accepted

How to track token issuance

It is exposed in the state under balances.totalIssuance, so the following will work - const total = await api.query.balances.totalIssuance(); console.log(total.toString()); For the parachain connect ...
Barto's user avatar
  • 584
7 votes
Accepted

Influence of Existential Deposits on account assets

The DOT transfer that empties the account will simply fail. First, an asset places a consumer reference on an account: frame_system::Pallet::<T>::inc_consumers(who).map_err(|_| Error::<T, I&...
joepetrowski's user avatar
  • 2,955
6 votes

How to transfer funds via Currency(Balance Pallet) in ink! smart contract?

If I understand your question correctly, you want to invoke a function in your smart contract that transfers your native chain token to another account. In ink! there is the function ink_env::transfer ...
cmichi's user avatar
  • 2,800
6 votes
Accepted

About some balance terminology

Burn: To remove some balance or asset from issuance. Slash: The reduce an account's balance as punishment. Reserve: To set aside some account's balance so it cannot be used in any other way but is ...
Gav's user avatar
  • 2,681
6 votes

Accidentally used ETH address to receive token from polkadot

Short answer: Not directly, you have to utilize governance (success not guaranteed). Ethereum uses the Elliptic Curve secp256k1 to derive a public key from a private key, whereas Polkadot uses the ...
sea212's user avatar
  • 549
5 votes
Accepted

How to deal with multiple currencies ED?

You are correct that when an account's balance drops below the existential deposit, its state is removed from the storage to not bloat up the precious on-chain storage. The handling of the remaining ...
William Freudenberger's user avatar
5 votes
Accepted

Can I transfer the balance to the same address on Polkadot?

Yes you can, and you will pay for the fees of such a transaction. And take care of not reaping your account when doing this interaction.What can be avoided by using KeepAlive when transacting any ...
Alejandro Martínez's user avatar
5 votes
Accepted

Where do the transaction fees go to?

The transaction-fee pallet handles calculating and transferring the transaction fees. It supports a configurable output by implementing the OnUnbalanced trait. For Polkadot and Kusama, 80% of the ...
Shawn Tabrizi's user avatar
  • 16.1k
5 votes
Accepted

Difference between ReservableCurrency and NamedReservableCurrency?

The context for NamedReserveableCurrency can be found here: https://github.com/paritytech/substrate/issues/7223 https://github.com/paritytech/substrate/pull/7778 Basically, this was a feature added ...
Shawn Tabrizi's user avatar
  • 16.1k
5 votes

How does the AccountData type work in FRAME runtimes?

I believe I'd asked a similar question on stackoverflow a while ago and it may answer your question: https://stackoverflow.com/questions/70845959/balances-accountstore-definition-in-substrate-runtime ...
Purple_Turtle's user avatar
4 votes
Accepted

How to overwrite endowed account balances using additional accounts and balances from a JSON file for genesis block inclusion?

So you could create a function in you chain_spec.rs like this: pub fn get_endowed_accounts_with_balance() -> Vec<(AccountId, u128)> { let accounts: Vec<AccountId> = vec![ ...
Bruno's user avatar
  • 8,315
4 votes

How does `pallet-bags-list` account for total issuance?

Question: In the docs for CurrencyToVote it says the total issuance being passed in implies that the implementation must be aware of the fact that its values can affect the outcome. This implies that ...
zekemostov's user avatar
4 votes
Accepted

Need help understanding deposit event

It's because that account reported a GRANDPA equivocation and the slash was enacted.
joepetrowski's user avatar
  • 2,955
4 votes
Accepted

How to format balance?

Good question. You could try something like this: import { ApiPromise, WsProvider } from '@polkadot/api'; import { BN, formatBalance } from '@polkadot/util'; const formatAccountBalance = async () =&...
Bruno's user avatar
  • 8,315
4 votes
Accepted

How to get a percent portion of a balance?

There is actually a function as part of the Imbalance trait to handle exactly this: ration. You can see an example of its use to split transaction fees between the Treasury and block author in ...
joepetrowski's user avatar
  • 2,955
4 votes
Accepted

Balance transfer fails when sending to the AccountIndex

This is not supported on-chain: https://github.com/paritytech/polkadot/blob/fb2c9ae0eece5a79356f7e7271cf3232f0143b0c/runtime/westend/src/lib.rs#L155 You always need to do the id lookup off-chain. ...
Bruno's user avatar
  • 8,315
4 votes

How does a Substrate chain set the max total supply?

The Balances pallet itself does not have logic which allows for a max supply of the token. In fact, the Balances pallet has no logic which itself automatically increases or decreases the total balance ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes
Accepted

Using Polkadot-JS to have third party wallet pay for dot transaction fee

The signer is always the account that pays all transaction fees. Trying to sign on one and then sending on another, won't yield results. At best where the two accounts have equal nonces it will be ...
Xiu Hung's user avatar
  • 527
4 votes
Accepted

How to manage storage when a pallet is instantiated more than once?

I believe you need to adjust the AccountStore type in the second balances pallet instance to store the balances in the Balances pallet storage. See the docs here: https://github.com/paritytech/...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes
Accepted

Is it possible to transfer balance from multiple accounts to the same receiver in a single Extrinsic?

You can do this using derivative accounts. See this blog post for an example, although it's not exactly what you're looking for. You've correctly spotted that a batch of extrinsics all must come from ...
joepetrowski's user avatar
  • 2,955
3 votes

How to get the token balance(rmrk) by py-substrate?

from substrateinterface import SubstrateInterface ASSET_ID = 8 # RMRK.app ACCOUNT = '<<YOUR_ACCOUNT>>' substrate = SubstrateInterface(url='wss://statemine-rpc.polkadot.io') account_info ...
Artur Gontijo's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible