The Framework for Runtime Aggregation of Modularized Entities (FRAME) is a set of modules (called pallets) and support libraries that simplify runtime development. Pallets are individual modules within FRAME that host domain-specific logic.
FRAME provides some helper modules to interact with Substrate Primitives, which provide the interface to the core client.
The following diagram shows the architectural overview of FRAME and its support libraries:
When building with FRAME, the Substrate runtime is composed of several smaller components called pallets. A pallet contains a set of types, storage items, and functions that define a set of features and functionality for a runtime.
The System library provides low-level types, storage, and functions for your blockchain. All other pallets depend on the System library as the basis of your Substrate runtime.
The System library defines all the core types for the Substrate runtime, such as:
- Block Number
- Account Id
It also has a number of system-critical storage items, such as:
- Account Nonce
- Block Hash
- Block Number
Finally, it defines a number of low level functions which can access your blockchain storage, verify the origin of an extrinsic, and more.
The FRAME Executive module acts as the orchestration layer for the runtime. It dispatches incoming extrinsic calls to the respective pallets in the runtime.
The FRAME Support library is a collection of Rust macros, types, traits, and functions that simplify the development of Substrate pallets.
The support macros expand at compile time to generate code that is used by the runtime and reduce boilerplate code for the most common components of a pallet.
The runtime library brings together all these components and pallets. It defines which pallets are included with your runtime and configures them to work together to compose your final runtime. When calls are made to your runtime, it uses the Executive pallet to dispatch those calls to the individual pallets.
Macro for benchmarking a FRAME runtime.
Some pallets will be sufficiently general-purpose to be reused in many blockchains. Anyone is free to write and share useful pallets. There is a collection of popular pallets provided with Substrate. Let's explore them.
The Assets pallet is a simple, secure module for dealing with fungible assets.
A module for atomically sending funds from an origin to a target. A proof is used to allow the target to approve (claim) the swap. If the swap is not claimed within a specified duration of time, the sender may cancel it.
The Aura pallet extends Aura consensus by managing offline reporting.
The Authority Discovery pallet is used by
core/authority-discovery to retrieve the current set of authorities, learn its own authority ID, as well as to sign and verify messages to and from other authorities.
The Authorship pallet tracks the current author of the block and recent uncles.
The BABE pallet extends BABE consensus by collecting on-chain randomness from VRF outputs and managing epoch transitions.
The Balances pallet provides functionality for handling accounts and balances.
A pallet that contains common runtime patterns in an isolated manner. This pallet is not meant to be used in a production blockchain, just for benchmarking and testing purposes.
The Collective pallet allows a set of account IDs to make their collective feelings known through dispatched calls from specialized origins.
The Contracts pallet provides functionality for the runtime to deploy and execute WebAssembly smart-contracts.
The Democracy pallet provides a democratic system that handles administration of general stakeholder voting.
The Phragmen Elections pallet is an election module based on sequential phragmen.
The Elections pallet is an election module for stake-weighted membership selection of a collective.
The EVM pallet is an Ethereum virtual machine (EVM) execution module for Substrate.
Example Offchain Worker
The Offchain Worker Example: A simple pallet demonstrating concepts, APIs and structures common to most offchain workers.
The Example pallet is a simple example of a pallet demonstrating concepts, APIs, and structures common to most pallets.
The Finality Tracker pallet tracks the last finalized block, as perceived by block authors.
The Generic Asset pallet provides functionality for handling accounts and asset balances.
The GRANDPA pallet extends GRANDPA consensus by managing the GRANDPA authority set ready for the native code.
A federated naming system, allowing for multiple registrars to be added from a specified origin. Registrars can set a fee to provide identity-verification service. Anyone can put forth a proposed identity for a fixed deposit and ask for review by any number of registrars (paying each of their fees). Registrar judgements are given as an enum, allowing for sophisticated, multi-tier opinions.
The I'm Online pallet allows validators to gossip a heartbeat transaction with each new session to signal that the node is online.
The Indices pallet allocates indices for newly created accounts. An index is a short form of an address.
The Membership pallet allows control of membership of a set of
AccountIds, useful for managing membership of a collective.
A module for doing multi-signature dispatches.
Nicks is a trivial module for keeping track of account names on-chain. It makes no effort to create a name hierarchy, be a DNS replacement or provide reverse lookups.
The Offences pallet tracks reported offences.
A module allowing accounts to give permission to other accounts to dispatch types of calls from their signed origin.
Randomness Collective Flip
The Randomness Collective Flip pallet provides a
random function that can be used in tests and generates low-influence random values based on the block hashes from the previous
81 blocks. This pallet is not intended for use in production.
The Recovery pallet is an M-of-N social recovery tool for users to gain access to their accounts if the private key or other authentication mechanism is lost. Through this pallet, a user is able to make calls on-behalf-of another account which they have recovered. The recovery process is protected by trusted "friends" whom the original account owner chooses. A threshold (M) out of N friends are needed to give another account access to the recoverable account.
This module exposes capabilities for scheduling dispatches to occur at a specified block number or at a specified period. These scheduled dispatches may be named or anonymous and may be canceled.
The Scored Pool pallet maintains a scored membership pool where the highest scoring entities are made members.
The Session pallet allows validators to manage their session keys, provides a function for changing the session length, and handles session rotation.
The Society module is an economic game which incentivizes users to participate and maintain a membership society.
The Staking pallet is used to manage funds at stake by network maintainers.
The Sudo pallet allows for a single account (called the "sudo key") to execute dispatchable functions that require a
Root origin or designate a new account to replace them as the sudo key.
The Timestamp pallet provides functionality to get and set the on-chain time.
The Transaction Payment pallet provides the basic logic to compute pre-dispatch transaction fees.
The Treasury pallet provides a "pot" of funds that can be managed by stakeholders in the system and a structure for making spending proposals from this pot.
A stateless module with helpers for dispatch management.
A simple module providing a means of placing a linear curve on an account's locked balance. This module ensures that there is a lock in place preventing the balance to drop below the unvested amount for any reason other than transaction fee payment.
- Learn how to develop custom Substrate pallets.