13 releases (1 stable)

2.0.0 Sep 22, 2020
2.0.0-rc6 Aug 20, 2020
2.0.0-rc5 Jul 24, 2020
2.0.0-rc4 Jun 25, 2020
2.0.0-alpha.3 Feb 27, 2020

#7 in Cryptocurrencies

Download history 648/week @ 2020-06-25 448/week @ 2020-07-02 455/week @ 2020-07-09 484/week @ 2020-07-16 477/week @ 2020-07-23 703/week @ 2020-07-30 692/week @ 2020-08-06 737/week @ 2020-08-13 837/week @ 2020-08-20 774/week @ 2020-08-27 562/week @ 2020-09-03 806/week @ 2020-09-10 871/week @ 2020-09-17 1672/week @ 2020-09-24 1151/week @ 2020-10-01 1077/week @ 2020-10-08

2,789 downloads per month
Used in 105 crates (92 directly)

Apache-2.0

1MB
22K 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 Module) 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 Module 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::Index.
  • [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

use frame_support::{decl_module, dispatch};
use frame_system::{self as system, ensure_signed};

pub trait Trait: system::Trait {}

decl_module! {
	pub struct Module<T: Trait> for enum Call where origin: T::Origin {
		#[weight = 0]
		pub fn system_module_example(origin) -> dispatch::DispatchResult {
			let _sender = ensure_signed(origin)?;
			let _extrinsic_count = <system::Module<T>>::extrinsic_count();
			let _parent_hash = <system::Module<T>>::parent_hash();
			Ok(())
		}
	}
}

License: Apache-2.0

Dependencies

~2.6–5.5MB
~105K SLoC