如果我们查看Polkadot JS文档,可以看到以下说明:
这仅在使用此面板存储余额的情况下使用。
那么我们如何使用balances面板来存储余额呢?因为我们还有
api.query.system.account
函数,而不是api.query.balances.account
。api.query.system.account
函数,而不是api.query.balances.account
。您可以在框架系统和托盘平衡器的 Config
特征中进行配置。
在我们的示例中,我们使用以下设置,将平衡器放置在系统托盘中:
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>;
}
我在相关字段上放了一个箭头。
如果您想将余额存储在余额面板中,只需将这两行更改为以下内容:
/// Store no extra data in the Frame System pallet.
type AccountData = ();
和
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>,
>;
the trait bound `pallet_balances::Pallet: StoredMap>` 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`
|
我正在使用 Substrate 节点模板 3.0.0。 - Noah Bergh