Make Balances Configurable
There is nothing new to learn in this step, just repeating the same process we did for our System Pallet for the Balances pallet.
In this case, our Config trait will only have two associated types: AccountId and Balance.
For this step, try to avoid looking at the solution, and instead refer to the changes you made to get the System Pallet configurable.
- Define the
Configtrait which will have your associated types. - Make sure these types have their trait constraints defined in
Config. - Update your
struct Palletto useT: Configand reference your types using theT::syntax. - Update all of your functions to use the
T::syntax. - Update your test, creating a struct
TestConfig, and implementingConfigfor it, and using it to instantiate yourPalletstruct. - Go to your
main.rsfile, and implementbalances::Configfor theRuntimestruct. - Update your
Runtimedefinition to instantiatebalances::PalletwithSelf.
If you have made it this far, I think it is fair to say you have made it over the hardest part of this tutorial, and the hardest part of using Rust in Substrate.
It is important to take a step back and remember that while these abstractions make your code a bit more complicated to fully understand, it also makes your code extremely flexible, at zero cost to performance and safety thanks to the Rust compiler.