Substrate Framework

Reference Material

Substrate foundations

Parity company is developing massive component for Substrate: https://github.com/paritytech

Frame is: 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, see https://substrate.dev/docs/en/knowledgebase/runtime/frame

Pallet: set of component/module, like small lib/component for runtime function in Frame. Pallet contains a set of types, storage items, and functions that define a set of features and functionality for a runtime.

The Contract Pallet: The Contracts pallet provides functionality for the runtime to deploy and execute WebAssembly smart-contracts.

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.

Rocksdb: This is the Database used on Substrate node. This has been invented by Facebook team: https://github.com/facebook/rocksdb/wiki/RocksDB-Basics , https://rocksdb.org/docs/getting-started.html, it is based on leveldb invented at Google (https://github.com/google/leveldb)

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.

Consensus mechanisms used by Substrate:

  • Babe: BABE (Blind Assignment for Blockchain Extension) is the block production mechanism that runs between the validator nodes and determines the authors of new blocks.

  • GRANDPA (GHOST-based Recursive ANcestor Deriving Prefix Agreement) is the finality gadget that is implemented for the Polkadot Relay Chain.

Your First Substrate-Chain

// https://substrate.dev/docs/en/knowledgebase/getting-started/
// Setup Rust Env on MAC:
$ brew update
$ brew install openssl cmake

// Install RUST (compiler rustc, meta data and toolchain rustup, and package manager: Cargo)
// https://rustup.rs is an installer system for RUST Programming language

$ sudo curl https://sh.rustup.rs -sSf | sh
// select 1 for Default installation
// Set CARGO_HOME environment variable
$ source ~/.cargo/env
// Configure the Rust toolchain to default to the latest stable version:
$ rustup default stable

// Install a specific Rust nightly version that is known to be compatible with the version of Substrate
$ rustup install nightly-2020-10-05 
// -->> !! issue with the 10-05, use the 10-06 > https://github.com/substrate-developer-hub/substrate-node-template/issues/90

$ rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
// run this in the project folder: /substrate/myFirstSubstrate
$ WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo build --release
$ rustup update
$ rustup update nightly
$ rustup target add wasm32-unknown-unknown --toolchain nightly



// Create your first substrate chain (and node with Rust compiled and WASM)
https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup
// Test it: https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/interact

Adding a Pallet to the FRAME runtime on Substrate

Details is explained here: https://substrate.dev/docs/en/tutorials/add-a-pallet/

Last updated