• what are the use cases for this macro?
  • what does it mean to specify an origin for the pallet? does it mean that all extrinsics defined within that pallet will be available only for origin?
  • can someone provide a useful example and how to use?

2 Answers 2


It's always good to search these in the Substrate repository. And here's the document.


  1. Use it when you want to customize your pallet origin.
  2. It will apply your origin to OriginFor<T>, when you use ensure_sign it will verify your origin.
  3. Let's take the collective as an example.

Define an origin first: https://github.com/paritytech/substrate/blob/41ae90843b070786ab53071479c141a7c6649ac9/frame/collective/src/lib.rs#L131-L151.

Override the RuntimeOrigin: https://github.com/paritytech/substrate/blob/41ae90843b070786ab53071479c141a7c6649ac9/frame/collective/src/lib.rs#L186

Then use this macro to "activate" it: https://github.com/paritytech/substrate/blob/41ae90843b070786ab53071479c141a7c6649ac9/frame/collective/src/lib.rs#L248-L250.

You can search the keyword RawOrigin within this pallet to get more details.


The #[pallet::origin] attribute allows you to define some origin for the pallet. The annotated item must be either a type alias, an enum, or a struct and it needs to be public.

The way frame processes these macros is to simply look at them as labels for the #[frame_support::pallet] macro. There is no additional Rust code being generated when you see such macros.

The use case for this macro can be seen in a number of pallets, two of them that comes to mind being the frame_system pallet which is a core pallet and defines the RuntimeOrigin that's used throughout the runtime: https://github.com/paritytech/substrate/blob/master/frame/system/src/lib.rs#L542

And the other being pallet_collective which defines a custom origin like so:

pub enum RawOrigin<AccountId, I> {
    /// It has been condoned by a given number of members of the collective from a given total.
    Members(MemberCount, MemberCount),
    /// It has been condoned by a single member of the collective.
    /// Dummy to manage the fact we have instancing.

what does it mean to specify an origin for the pallet? does it mean that all extrinsics defined within that pallet will be available only for origin?

That depends on the pallet code. Collective for instance defines its "RuntimeOrigin" as :

type RuntimeOrigin: From<RawOrigin<Self::AccountId, I>>;

Where confusingly, RawOrigin is collective's own version, and not the same thing that's used by frame_system. All that matters is the Call enum that's generated by the construct_runtime! macro implements Dispatchable<RuntimeOrigin = <Self as Config<I>>::RuntimeOrigin, PostInfo = PostDispatchInfo,> to be able to call Call using the origin type that was defined in the pallet, which in our case is RuntimeOrigin which is pallet_collective's own version:

// Inside pallet_collective::Config
type RuntimeOrigin: From<pallet_collective::RawOrigin<Self::AccountId, I>>;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.