32 releases (18 major breaking)

new 20.0.0 Mar 26, 2023
19.0.0 Mar 5, 2023
18.0.0 Feb 26, 2023
17.0.0 Feb 19, 2023
2.0.0-alpha.5 Mar 24, 2020

#1313 in Magic Beans

Download history 777/week @ 2022-12-04 1074/week @ 2022-12-11 857/week @ 2022-12-18 419/week @ 2022-12-25 256/week @ 2023-01-01 672/week @ 2023-01-08 428/week @ 2023-01-15 935/week @ 2023-01-22 1050/week @ 2023-01-29 716/week @ 2023-02-05 347/week @ 2023-02-12 1087/week @ 2023-02-19 122/week @ 2023-02-26 1269/week @ 2023-03-05 393/week @ 2023-03-12 665/week @ 2023-03-19

2,452 downloads per month
Used in 2 crates (via suntime)


34K SLoC

Sudo Module


The Sudo module allows for a single account (called the "sudo key") to execute dispatchable functions that require a Root call or designate a new account to replace them as the sudo key. Only one account can be the sudo key at a time.


Dispatchable Functions

Only the sudo key can call the dispatchable functions from the Sudo module.

  • sudo - Make a Root call to a dispatchable function.
  • set_key - Assign a new account to be the sudo key.


Executing Privileged Functions

The Sudo module itself is not intended to be used within other modules. Instead, you can build "privileged functions" (i.e. functions that require Root origin) in other modules. You can execute these privileged functions by calling sudo with the sudo key account. 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 module that exposes a privileged function:

pub mod pallet {
    use super::*;
    use frame_support::pallet_prelude::*;
    use frame_system::pallet_prelude::*;

    pub struct Pallet<T>(_);

    pub trait Config: frame_system::Config {}

    impl<T: Config> Pallet<T> {
        pub fn privileged_function(origin: OriginFor<T>) -> DispatchResult {

            // do something...


Genesis Config

The Sudo module depends on the GenesisConfig. You need to set an initial superuser account as the sudo key.

License: Apache-2.0


~737K SLoC