rectangles-mixedUnderstanding the architecture

Overall architecture of a Substrate blockchain

We will use the Partiy minimal template for a Substrate blockchain to guide you through the concepts: https://github.com/paritytech/polkadot-sdk/tree/master/templates/minimal/arrow-up-right

Alternative repository that you can consider reference from: https://github.com/paritytech/polkadot-sdk-solochain-templatearrow-up-right

  1. Runtime

In Substrate, the terms "runtime" and "state transition function" are analogous. Both terms refer to the core logic of the blockchain that is responsible for validating blocks and executing the state changes they define. The Substrate project in this repository uses FRAMEarrow-up-right to construct a blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules called "pallets". At the heart of FRAME is a helpful macro languagearrow-up-right that makes it easy to create pallets and flexibly compose them to create blockchains that can address a variety of needsarrow-up-right.

Review the FRAME runtime implementationarrow-up-right included in this template and note the following:

  1. Node

Break down the node architecturechevron-right
  1. Pallets

Adding a new logic to the new blockchain is like playing with LEGO blocks

The runtime in this project is constructed using many FRAME pallets that ship with the Substrate repositoryarrow-up-right and a template pallet that is defined in the palletsarrow-up-right directory.

A FRAME pallet is comprised of a number of blockchain primitives, including:

  • Storage: FRAME defines a rich set of powerful storage abstractionsarrow-up-right that makes it easy to use Substrate's efficient key-value database to manage the evolving state of a blockchain.

  • Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched) from outside of the runtime in order to update its state.

  • Events: Substrate uses eventsarrow-up-right to notify users of significant state changes.

  • Errors: When a dispatchable fails, it returns an error.

Each pallet has its own Config trait which serves as a configuration interface to generically define the types and parameters it depends on.

Code walkthrough

Last updated