Crates.io | pallet-sudo |
lib.rs | pallet-sudo |
version | 38.0.0 |
source | src |
created_at | 2020-02-27 10:03:12.738682 |
updated_at | 2024-09-26 08:36:59.356502 |
description | FRAME pallet for sudo |
homepage | https://paritytech.github.io/polkadot-sdk/ |
repository | https://github.com/paritytech/polkadot-sdk.git |
max_upload_size | |
id | 213043 |
size | 42,802 |
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.
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.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.
This is an example of a module that exposes a privileged function:
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight(0)]
pub fn privileged_function(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
// do something...
Ok(())
}
}
}
The Sudo module depends on the GenesisConfig
.
You need to set an initial superuser account as the sudo key
.
License: Apache-2.0
Polkadot SDK stable2409