Expand description

SudoOrigin Pallet

Overview

The SudoOrigin pallet allows for an origin to execute dispatchable functions that require a Root call.

Interface

Dispatchable Functions

Only the sudo origin can call the dispatchable functions from the SudoOrigin pallet.

  • sudo - Make a Root call to a dispatchable function.

Usage

Executing Privileged Functions

The SudoOrigin pallet is intended to be used with the Council. The council can use this pallet to make Root calls You can build “privileged functions” (i.e. functions that require Root origin) in other pallets. You can execute these privileged functions by calling sudo with the sudo origin. Privileged functions cannot be directly executed via an extrinsic.

Learn more about privileged functions and Root origin in the Origin type documentation.

Simple Code Snippet

This is an example of a pallet that exposes a privileged function:


#[frame_support::pallet]
pub mod logger {
	use frame_support::pallet_prelude::*;
	use frame_system::pallet_prelude::*;
	use super::*;

	#[pallet::config]
	pub trait Config: frame_system::Config {}

	#[pallet::pallet]
	pub struct Pallet<T>(PhantomData<T>);

	#[pallet::call]
	impl<T: Config> Pallet<T> {
		#[pallet::weight(0)]
        pub fn privileged_function(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
            ensure_root(origin)?;

            // do something...

            Ok(().into())
        }
	}
}

Genesis Config

The SudoOrigin pallet depends on the runtiem config.

  • Collective

Re-exports

Modules

  • The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.

Macros