[][src]Crate frame_system

System Module

The System module provides low-level access to core types and cross-cutting utilities. It acts as the base layer for other SRML modules 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 runtime modules.

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:

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 {
		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(())
		}
	}
}

Modules

offchain

Module helpers for offchain calls.

Structs

AccountNonce

Extrinsics nonce for accounts.

BlockHash

Map of block numbers to block hashes.

ChainContext
CheckEra

Check for transaction mortality.

CheckGenesis

Nonce check and increment to give replay protection for transactions.

CheckNonce

Nonce check and increment to give replay protection for transactions.

CheckVersion

Ensure the runtime version registered in the transaction is the same as at present.

CheckWeight

resource limit check.

EnsureNever
EnsureNone
EnsureRoot
EnsureSigned
EnsureSignedBy
EventRecord

Record of an event happening.

GenesisConfig
Module

Enums

Call

Dispatchable calls.

Error

Error for the System module

Event

Events for this module.

Phase

A phase of a block's execution.

RawOrigin

Origin for the System module.

Traits

IsDeadAccount

Determiner to say whether a given account is unused.

OnNewAccount

Handler for when a new account has been created.

Trait

Functions

ensure_none

Ensure that the origin o represents an unsigned extrinsic. Returns Ok or an Err otherwise.

ensure_root

Ensure that the origin o represents the root. Returns Ok or an Err otherwise.

ensure_signed

Ensure that the origin o represents a signed extrinsic (i.e. transaction). Returns Ok with the account that signed the extrinsic or an Err otherwise.

extrinsics_data_root

Compute the trie root of a list of extrinsics.

extrinsics_root

Compute the trie root of a list of extrinsics.

Type Definitions

DigestItemOf
DigestOf
Key
KeyValue
Origin

Exposed trait-generic origin type.