Attribute Macro frame_support::pallet_macros::origin

source ·
#[origin]
Expand description

Allows a pallet to declare a type as an origin.

If defined as such, this type will be amalgamated at the runtime level into RuntimeOrigin, very similar to call, error and event. See composite_enum for similar cases.

Origin is a complex FRAME topics and is further explained in polkadot_sdk_docs.

§Syntax Variants

#[frame_support::pallet]
mod pallet {
	/// On the spot declaration.
    #[pallet::origin]
	#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
	pub enum Origin {
		Foo,
		Bar,
	}
}

Or, more commonly used:

#[frame_support::pallet]
mod pallet {
	#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
	pub enum RawOrigin {
		Foo,
		Bar,
	}

	#[pallet::origin]
	pub type Origin = RawOrigin;
}

§Warning

Modifying any pallet’s origin type will cause the runtime level origin type to also change in encoding. If stored anywhere on-chain, this will require a data migration.

Read more about origins at the Origin Reference Docs.


Documentation for this macro can be found at frame_support::pallet_macros::origin.