[][src]Crate srml_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.

Usage

Prerequisites

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

Example - Get random seed and extrinsic count for the current block

use srml_support::{decl_module, dispatch::Result};
use srml_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) -> Result {
            let _sender = ensure_signed(origin)?;
            let _random_seed = <system::Module<T>>::random_seed();
            let _extrinsic_count = <system::Module<T>>::extrinsic_count();
            Ok(())
        }
    }
}

Structs

AccountNonce

Extrinsics nonce for accounts.

BlockHash

Map of block numbers to block hashes.

ChainContext
EnsureRoot
EventRecord

Record of an event happening.

GenesisConfig
Module

Enums

Call
Event

Events for this module.

Phase

A phase of a block's execution.

RawLog

A log in this module.

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_inherent

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
Log
Origin

Exposed trait-generic origin type.