If we take a look at the polkadot js documentation we can see the following note:
This is only used in the case that this pallet is used to store balances.
Now how do we use the balances pallet to store the balances? because we also have the api.query.system.account
function instead of api.query.balances.account
Asked
Active
Viewed 943 times
9

Noah Bergh
- 493
- 4
- 14
-
Hi Noah, Can you please support our Substrate StackExchange proposal: https://area51.stackexchange.com/proposals/126136 – Shawn Tabrizi Dec 16 '21 at 13:07
1 Answers
10
You can configure this in your Frame System and Pallet Balances Config
trait.
By in our examples we use the following which places the balances in the System Pallet:
impl frame_system::Config for Runtime {
/// The basic call filter to use in dispatchable.
type BaseCallFilter = ();
/// Block & extrinsics weights: base values and limits.
type BlockWeights = BlockWeights;
/* -- snip -- */
/// The data to be stored in an account.
--> type AccountData = pallet_balances::AccountData<Balance>;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = ();
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
type SS58Prefix = SS58Prefix;
}
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
--> type AccountStore = System;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
}
I have put an arrow over the relevant fields.
If you want to store the balances in the balances pallet itself, you can simply change those two lines to the following:
/// Store no extra data in the Frame System pallet.
type AccountData = ();
and
use frame_support::traits::StorageMapShim;
...
/// Store the balance information in the Balances pallet.
type AccountStore = StorageMapShim<
pallet_balances::Account<Runtime>,
frame_system::Provider<Runtime>,
AccountId,
pallet_balances::AccountData<Balance>,
>;

lovelikelando
- 7,593
- 6
- 32
- 50

Shawn Tabrizi
- 12,206
- 1
- 38
- 69
-
Thanks alot but with your adjustments i have the following error ``` the trait bound `pallet_balances::Pallet
: StoredMap – Noah Bergh Mar 07 '21 at 05:55>` is not satisfied --> /home/noone/cious3/substrate-node-template/runtime/src/lib.rs:280:2 | 280 | type AccountStore = Balances; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StoredMap >` is not implemented for `pallet_balances::Pallet ` | ``` I am using the substrate node template 3.0.0 -
1Sorry @NoahBergh! I have updated the sample to be correct and have tested it compiles and works locally. – Shawn Tabrizi Mar 07 '21 at 23:54