This is a minimal template for creating a blockchain based on Polkadot SDK.
This template is automatically updated after releases in the main Polkadot SDK monorepo.
-
🤏 This template is a minimal (in terms of complexity and the number of components) template for building a blockchain node.
-
🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets such as a Balances pallet.
-
👤 The template has no consensus configured - it is best for experimenting with a single node network.
A Polkadot SDK based project such as this one consists of:
- 🧮 the Runtime - the core logic of the blockchain.
- 🎨 the Pallets - from which the runtime is constructed.
- 💿 a Node - the binary application (which is not part of the cargo default-members list and is not compiled unless building the entire workspace).
-
🦀 The template is using the Rust language.
-
👉 Check the Rust installation instructions for your system.
-
🛠️ Depending on your operating system and Rust version, there might be additional packages required to compile this template - please take note of the Rust compiler output.
Fetch minimal template code:
git clone https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template
cd minimal-template
Omni Node can
be used to run the minimal template's runtime. polkadot-omni-node
binary crate usage is described at a high-level
on crates.io.
Please see installation section on crates.io/omni-node.
cargo build -p minimal-template-runtime --release
Please see the installation section at crates.io/staging-chain-spec-builder
.
chain-spec-builder create --relay-chain "dev" --para-id 1000 --runtime \
target/release/wbuild/minimal-template-runtime/minimal_template_runtime.wasm named-preset development
Note: the relay-chain
and para-id
flags are extra bits of information required to
configure the node for the case of representing a parachain that is connected to a relay chain.
They are not relevant to minimal template business logic, but they are mandatory information for
Omni Node, nonetheless.
Start Omni Node in development mode (sets up block production and finalization based on manual seal, sealing a new block every 3 seconds), with a minimal template runtime chain spec.
polkadot-omni-node --chain <path/to/chain_spec.json> --dev
cargo build --workspace --release
🐳 Alternatively, build the docker image which builds all the workspace members, and has as entry point the node binary:
docker build . -t polkadot-sdk-minimal-template
The minimal-template-node
has dependency on the minimal-template-runtime
. It will use
the minimal_template_runtime::WASM_BINARY
constant (which holds the WASM blob as a byte
array) for chain spec building, while starting. This is in contrast to Omni Node which doesn't
depend on a specific runtime, but asks for the chain spec at startup.
<target/release/path/to/minimal-template-node> --tmp --consensus manual-seal-3000
# or via docker
docker run --rm polkadot-sdk-minimal-template
We can install zombienet
as described here,
and zombienet-omni-node.toml
contains the network specification we want to start.
Before starting the network with zombienet we must update the network specification with a valid chain spec path. If we need to generate one, we can look up at the previous section for chain spec creation here.
Then make the changes in the network specification like so:
# ...
chain = "dev"
chain_spec_path = "<TO BE UPDATED WITH A VALID PATH>"
default_args = ["--dev"]
# ..
zombienet --provider native spawn zombienet-omni-node.toml
For this one we just need to have zombienet
installed and run:
zombienet --provider native spawn zombienet-multi-node.toml
-
🌐 You can interact with your local node using the hosted version of the Polkadot/Substrate Portal.
-
🪐 A hosted version is also available on IPFS.
-
🧑🔧 You can also find the source code and instructions for hosting your own instance in the
polkadot-js/apps
repository.
Previously minimal template's development chains:
- ❌ Started in a multi-node setup will produce forks because minimal lacks consensus.
- 🧹 Do not persist the state.
- 💰 Are pre-configured with a genesis state that includes several pre-funded development accounts.
- 🧑⚖️ One development account (
ALICE
) is used assudo
accounts.
-
🔄 This template is automatically updated after releases in the main Polkadot SDK monorepo.
-
➡️ Any pull requests should be directed to this source.
-
😇 Please refer to the monorepo's contribution guidelines and Code of Conduct.
-
🧑🏫 To learn about Polkadot in general, Polkadot.network website is a good starting point.
-
🧑🔧 For technical introduction, here are the Polkadot SDK documentation resources.
-
👥 Additionally, there are GitHub issues and Substrate StackExchange.