referrerpolicy=no-referrer-when-downgrade

Attribute Macro frame_support_procedural::runtime

source ·
#[runtime]
Expand description

Construct a runtime, with the given name and the given pallets.

§Example:

#[crate::runtime]
mod runtime {
	// The main runtime
	#[runtime::runtime]
	// Runtime Types to be generated
	#[runtime::derive(
		RuntimeCall,
		RuntimeEvent,
		RuntimeError,
		RuntimeOrigin,
		RuntimeFreezeReason,
		RuntimeHoldReason,
		RuntimeSlashReason,
		RuntimeLockId,
		RuntimeTask
	)]
	pub struct Runtime;

	// Use the concrete pallet type
	#[runtime::pallet_index(0)]
	pub type System = frame_system::Pallet<Runtime>;

	// Use path to the pallet
	#[runtime::pallet_index(1)]
	pub type Basic = pallet_basic;

	// Use the concrete pallet type with instance
	#[runtime::pallet_index(2)]
	pub type PalletWithInstance1 = pallet_with_instance::Pallet<Runtime, Instance1>;

	// Use path to the pallet with instance
	#[runtime::pallet_index(3)]
	pub type PalletWithInstance2 = pallet_with_instance<Instance2>;

	// Ensure that the runtime does not export the calls from the pallet
	#[runtime::pallet_index(4)]
	#[runtime::disable_call]
	#[deprecated = "example"]
	pub type PalletWithDisabledCall = pallet_with_disabled_call::Pallet<Runtime>;

	// Ensure that the runtime does not export the unsigned calls from the pallet
	#[runtime::pallet_index(5)]
	#[runtime::disable_unsigned]
	pub type PalletWithDisabledUnsigned = pallet_with_disabled_unsigned::Pallet<Runtime>;
}

§Supported Attributes:

§Legacy Ordering

An optional attribute can be defined as #[frame_support::runtime(legacy_ordering)] to ensure that the order of hooks is same as the order of pallets (and not based on the pallet_index). This is to support legacy runtimes and should be avoided for new ones.

§Note

The population of the genesis storage depends on the order of pallets. So, if one of your pallets depends on another pallet, the pallet that is depended upon needs to come before the pallet depending on it.

§Type definitions

  • The macro generates a type alias for each pallet to their Pallet. E.g. type System = frame_system::Pallet<Runtime>