48 releases (29 major breaking)

new 31.0.0 Mar 18, 2024
30.0.0 Feb 26, 2024
29.0.0 Feb 13, 2024
28.0.0 Jan 23, 2024
2.0.0-alpha.5 Mar 24, 2020

#834 in Magic Beans

Download history 2257/week @ 2023-11-27 1611/week @ 2023-12-04 3221/week @ 2023-12-11 2354/week @ 2023-12-18 1269/week @ 2023-12-25 1939/week @ 2024-01-01 3848/week @ 2024-01-08 2499/week @ 2024-01-15 2917/week @ 2024-01-22 2428/week @ 2024-01-29 2880/week @ 2024-02-05 4097/week @ 2024-02-12 4085/week @ 2024-02-19 4789/week @ 2024-02-26 3720/week @ 2024-03-04 1157/week @ 2024-03-11

14,134 downloads per month
Used in 383 crates (304 directly)

Apache-2.0

2.5MB
43K SLoC

System Module

The System module provides low-level access to core types and cross-cutting utilities. It acts as the base layer for other pallets to interact with the Substrate framework components.

Overview

The System module defines the core data types used in a Substrate runtime. It also provides several utility functions (see Pallet) for other FRAME pallets.

In addition, it manages the storage items for extrinsics data, indexes, event records, and digest items, among other things that support the execution of the current block.

It also handles low-level tasks like depositing logs, basic set up and take down of temporary storage entries, and access to previous block hashes.

Interface

Dispatchable Functions

The System module does not implement any dispatchable functions.

Public Functions

See the Pallet struct for details of publicly available functions.

Signed Extensions

The System module defines the following extensions:

  • CheckWeight: Checks the weight and length of the block and ensure that it does not exceed the limits.
  • CheckNonce: Checks the nonce of the transaction. Contains a single payload of type T::Nonce.
  • CheckEra: Checks the era of the transaction. Contains a single payload of type Era.
  • CheckGenesis: Checks the provided genesis hash of the transaction. Must be a part of the signed payload of the transaction.
  • CheckSpecVersion: Checks that the runtime version is the same as the one used to sign the transaction.
  • CheckTxVersion: Checks that the transaction version is the same as the one used to sign the transaction.

Lookup the runtime aggregator file (e.g. node/runtime) to see the full list of signed extensions included in a chain.

Usage

Prerequisites

Import the System module and derive your module's configuration trait from the system trait.

Example - Get extrinsic count and parent hash for the current block

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

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

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

    #[pallet::call]
    impl<T: Config> Pallet<T> {
        #[pallet::weight(0)]
        pub fn system_module_example(origin: OriginFor<T>) -> DispatchResult {
            let _sender = ensure_signed(origin)?;
            let _extrinsic_count = <system::Pallet<T>>::extrinsic_count();
            let _parent_hash = <system::Pallet<T>>::parent_hash();
            Ok(())
        }
    }
}

License: Apache-2.0

Dependencies

~15–34MB
~557K SLoC