Configuring genesis for Balances
All the power to you now that you're getting the hang of things—by no means anything to show-off about, but may as well start somewhere !
info
This is intended for beginners just getting started and want to get familiar with customizing their chain. Not all configurations will follow the same approach—this in fact is the most basic approach. Learn more in the related material section.
#
GoalLearn how to customize a chain's genesis configuration for the balances pallet.
#
Use casesInitialize balances for endowed accounts.
#
OverviewGenesis configuration is a useful tool for testing chain behaviour by defining an initial state for things such as accounts, balances, genesis for custom pallets, and more. Here is a simple guide on how to configure custom intial balances for a runtime, by modifying BalancesConfig in chainspec.rs
.
#
Steps#
1. Modify accountsIn chain_spec.rs
, modify the accounts-to-amount map to apply it to the set of all endowed accounts (this is how every node template is set up):
Alternatively, write out each account you would like to pre-seed, as shown below:
#
2. Modify balancesBy changing the right-hand-side value of the balances
tuple, you can customize the amount of each account. Take a look at the Rust documentation on how this is implemented. Let's modify things such that Alice's account is pre-seeded with 1<<10:
#
Examples#
Related material#
TutorialsContractsConfig
from the Add the Contracts Pallet tutorial.