Runtime
The runtime is the code that determines how to produce new blocks and how to process extrinsics on the chain.
Runtime Upgrades
In the Substrate ecosystem, the runtime is part of the block, which enables us to upgrade the runtime on the fly, as part of the block production mechanism. Learn more.
Pallets
The runtime is composed of modules called pallets. Each pallet is responsible for a specific area of functionality. For example:
- Balances — tracks token balances and handles transfers.
- Staking — manages validator registration, delegation, and rewards.
- NFTs — handles minting, transferring, and burning of non-fungible tokens.
- Timestamp — sets the on-chain clock each block via an inherent extrinsic.
Pallets expose extrinsics that users can call, storage that holds on-chain state, and events that are emitted when something changes.
Storage
The runtime maintains a key-value store that represents the current state of the chain. Every block may update this state based on the extrinsics it contains. The state root — a cryptographic hash of the entire storage — is included in the block header, making the state tamper-evident.
Execution
When a block is imported, the runtime executes each extrinsic in order:
- Validate the extrinsic (signature check, sufficient balance for fees, etc.).
- Dispatch the call to the relevant pallet.
- Apply state changes and emit events.
- Update the state root.
If an extrinsic fails, its state changes are rolled back but the fee is still charged.