[−][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 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 typeT::Index
.CheckEra
: Checks the era of the transaction. Contains a single payload of typeEra
.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(()) } } }
Modules
offchain | Module helpers for off-chain calls. |
Structs
Account | The full account information for a particular account ID. |
AccountInfo | Information of an account. |
BlockHash | Map of block numbers to block hashes. |
CallKillAccount | Event handler which calls kill_account when it happens. |
CallOnCreatedAccount | Event handler which calls on_created_account when it happens. |
ChainContext | |
CheckEra | Check for transaction mortality. |
CheckGenesis | Genesis hash check to provide replay protection between different networks. |
CheckMortality | Check for transaction mortality. |
CheckNonce | Nonce check and increment to give replay protection for transactions. |
CheckSpecVersion | Ensure the runtime version registered in the transaction is the same as at present. |
CheckTxVersion | Ensure the transaction version registered in the transaction is the same as at present. |
CheckWeight | Block resource (weight) limit check. |
EnsureNever | |
EnsureNone | |
EnsureOneOf | The "OR gate" implementation of |
EnsureRoot | |
EnsureSigned | |
EnsureSignedBy | |
EventRecord | Record of an event happening. |
GenesisConfig | Genesis config for the module, allow to build genesis storage. |
LastRuntimeUpgrade | Stores the |
LastRuntimeUpgradeInfo | Stores the |
Module |
Enums
Call | Dispatchable calls. |
Error | Error for the System module |
InitKind | A type of block initialization to perform. |
Phase | A phase of a block's execution. |
RawEvent | Events for this module. |
RawOrigin | Origin for the System module. |
RefStatus | Reference status; can be either referenced or unreferenced. |
Traits
Trait |
Functions
ensure_none | Ensure that the origin |
ensure_root | Ensure that the origin |
ensure_signed | Ensure that the origin |
extrinsics_data_root | Compute the trie root of a list of extrinsics. |
extrinsics_root | Compute the trie root of a list of extrinsics. |
split_inner | Split an |
Type Definitions
DigestItemOf | |
DigestOf | |
Event | |
Key | |
KeyValue | |
Origin | Exposed trait-generic origin type. |
RefCount | Type used to encode the number of references an account has. |