11

When is Assets pallet useful & when is Balances pallet used? Is Assets pallet similar to an ERC 20 token but implementation at runtime level?

1 Answer 1

15

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 actually move balances are very low.

There are two ways of storing balances when using the balances pallet. One way is to store the balance in the pallet itself. The other, more common way is to store the balance in Frame System's AccountData, specifically in Frame System's AccountInfo - which is nice because the balance is then stored on the Frame System level.

Additionally, the balances pallet has extra layers of abstractions beyond just Currency, like ReservableCurrency and LockableCurrency. You can see a full list of implementations here. And these abstractions combined with storing the balance on the Frame System level, enables balances to be really "useful" at the runtime level. For example, we lock balances for democracy and staking, allowing the same balance to be used twice across two services. On the other hand, we use reserved balances for a lot of things like storage deposits making sure that this kind of balance CANNOT be used twice.

The assets pallet is just a really simple way of representing some ERC-20 like token, the balances pallet is much more deeply designed for all of the things you would want to do with a blockchain currency the only main advantage of assets pallet is that it supports multiple assets being created in a single pallet whereas balances pallet is just a single token so in this case, you can think of the assets pallet as an ERC-20 like factory.

So in essence, you can create your underlying native currency using the balances pallet and if you need additional currencies you can leverage the assets pallet.

More info:

2
  • For Currency type of assets pallet I see Balances pallet is used in some codebase. So how are both pallet related?
    – llvm_ninja
    Mar 30, 2022 at 11:16
  • Currency is not a pallet, it is a trait defined by FRAME that pallet-balances implements. Jun 9, 2022 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.