Learn how to write a struct to manage your storage values.
Create a struct in
StorageValue and use it on
Keep track of different accounts and balances for testing a pallet.
Creating a struct of similarly grouped storage items is a neat way to keep track of them.
They can be easier to reference than keeping individual
StorageValue items separate this way.
In addition, they can be used to ease testing and genesis configuration.
This guide steps through the procedure of creating a struct in storage which:
- keeps track of an initial amount (
- keeps track of the account that receives that amount (
- keeps track of an account that can burn some amount (
- is (partially) used in
MetaData and declare its different types:
StorageValue to declare the struct as a new single item in storage:
#[pallet::genesis_config] to declare the admin account that you'll use in your to
initialize values from your
#[pallet::genesis_build] to initialize the values of your struct, using
admin to initialize the values
4. Use the struct in
Assign an amount to the
issuance field of
MetaData to be initialized when the chain is launched: