There's gotta be a better way than re-writing the same pallet twice...
This guide is based on FRAME v1 macros.
Learn how to configure instantiable pallets.
- A token chain hosts two independent cryptocurrencies.
- Governance has two (or more) houses which act similarly internally.
- A social network chain that maintains different treasuries.
The premise of instantiable pallets is to provide separate storage items for a runtime that contains more than one reference to the same pallet. This can be useful in cases where you may need to reuse the logic provided by a single pallet. This recipe guides you through how to create two instances of the same pallet and how to configure their capabilities.
1. Implement the
Instantiable pallets must call the
decl_storage! macro so that the
Instance type is created.
Add a generic type for
Instance in the Config trait, Event type, and Store trait. Learn more about how generic types work in Rust here. The code snippet below shows the modifications required for our pallet's
Include two instances of