Deploy a substrate permissioned network using python
Project description
PySubnet
The easiest way to /develop/deploy/test a multi-node substrate network
๐ What is PySubnet?
PySubnet is a beginner-friendly tool that automates the complex process of setting up multi-node Substrate blockchain networks. Whether you're a blockchain developer learning Substrate or deploying production networks, PySubnet handles all the tedious setup work for you.
โจ What PySubnet Does for You:
- ๐ Generates all cryptographic keys for your validator authorities (AURA, BABE, GRANDPA)
- ๐ Creates proper directory structure for your network nodes
- โ๏ธ Prepares a chainspec with bootnodes and validator keys
- ๐ Sets up p2p keys (libp2p keys for bootnodes list)
- ๐ธ Funds starting balances for any number of accounts for you without having to manually edit chainspec files. (See example in nodes.toml)
- ๐โโ๏ธ Launches your network with a single command (
-r) - ๐จ Interactive CLI with beautiful, colorful output (
-i)
Crafted For:
- Blockchain Developers learning the Substrate framework with multi-node setups
- DevOps Teams for managing multiple sets of keys for separate nodes
- Rapid Prototyping of blockchain applications
๐ฆ Installation
Option 1: Install with uv pip (Recommended)
uv pip install pysubnet
# or install it as a tool
uv tool install pysubnet
Option 2: Latest from GitHub
pip install git+https://github.com/weezy20/pysubnet.git
Option 3: Run without installing (using uvx)
uvx git+https://github.com/weezy20/pysubnet.git
๐ก Tip: If you get Python header errors during installation:
- Ubuntu/Debian:
sudo apt install python3-dev- RHEL/Fedora:
sudo dnf install python3-devel- macOS:
xcode-select --install
Step 2: Run PySubnet
pysubnet
That's it! PySubnet will automatically start in interactive mode and guide you through the setup.
Step 3: Choose Your Network Type
PySubnet will present you with 5 commonly used consensus options:
- ๐ข PoA (Proof-of-Authority) - Perfect for learning and simple development
- ๐ก PoA + ValidatorSet - PoA with sessions pallet and substrate-validator-pallet for dynamic authority management
Note: To use this pallet (substrate-validator-set) it's recommended to clone it locally and add it to your runtime because as of this writing, it's dependecies seem outdated, but its functionality is unaffected - ๐ต BABE + GRANDPA - Production-ready consensus (like Polkadot)
- ๐ฃ BABE + GRANDPA + Staking - Full production setup with economic security
- ๐ด Development Mode - Single node for rapid development
๐ฎ Interactive Mode Features
When you run pysubnet, it automatically detects if you have a substrate binary and provides:
- ๐จ Beautiful CLI interface with colors and progress bars
- ๐ค Smart substrate detection - automatically switches to interactive mode if no binary found
- โ Helpful prompts - clear explanations for each option
- ๐ง Flexible configuration - choose exactly what you need
- ๐ Real-time feedback - see your network being built step by step
๐ง Advanced Usage
Non-Interactive Mode
# Quick setup with defaults
pysubnet --clean --run
# Or a shorter version
pysubnet -cr
# Custom binary location
pysubnet --bin ./target/release/my-node --run
# Using Docker
pysubnet --docker substrate:latest --run
# Custom chainspec
pysubnet --chainspec ./my-chainspec.json --run
Configuration File
Create advanced network configurations:
pysubnet --config ./network-config.toml --run
See docs/config.md for configuration examples.
Directory Structure
PySubnet creates organized directories:
./network/ # Default root directory
โโโ pysubnet.json # Network configuration & keys
โโโ chainspec.json # Generated chainspec
โโโ raw_chainspec.json # Raw chainspec for nodes
โโโ alice/ # Node directories
โ โโโ alice-node-private-key
โ โโโ chains/<chain folder based on running chainspec>/keystore/
โโโ bob/
โโโ charlie/
๐ Complete Flag Reference
| Flag | Description | Example |
|---|---|---|
-i, --interactive |
Force interactive mode (default when no substrate binary) | pysubnet -i |
-r, --run |
Launch network after setup | pysubnet -r |
-c, --clean |
Clean existing network directory | pysubnet -c |
--root |
Custom network directory | --root ./my-network |
--bin |
Path to substrate binary | --bin ./substrate |
--docker |
Use Docker image | --docker substrate:latest |
--chainspec |
Base chainspec (dev, local, or file path) |
--chainspec dev |
--config |
Network configuration file | --config ./config.toml |
--account |
Account type (ecdsa or sr25519) |
--account ecdsa |
--poa |
Force basic PoA mode (bypass interactive selection) | --poa |
๐ Learning Resources
New to Substrate?
The first tutorial on substrate is about running a PoA node with 2 or 3 nodes. You can replicate that entire tutorial with pysubnet by running pysubnet -icr --poa --bin <your poa enabled node>.
๐ค Getting Help
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- All node data (crypto keys, Account keys, libp2p keys, node IDs) is stored in
pysubnet.json. - The script auto-generates keystores compatible with Substrateโs expected format.
๐ก Tips & Best Practices
- ๐งน Always use
--clean/-cwhen restarting development to avoid issues. - ๐ Save your pysubnet.json - After having a proper setup, save this file for your future reference, it contains all your network keys and configuration
๐ What's New in v2.0
- ๐ฏ 5 Consensus Options (upgraded from 2)
- ๐จ Enhanced Interactive Mode with beautiful CLI
- ๐ค Smart Binary Detection with automatic fallback
- ๐ฆ Modular Architecture for easier customization
Made with โค๏ธ for the Substrate community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysubnet-2.2.0.tar.gz.
File metadata
- Download URL: pysubnet-2.2.0.tar.gz
- Upload date:
- Size: 4.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e8f515724d770e2f66df44b8dce28989e96a565e33f5e419f4977c73da41969
|
|
| MD5 |
647c0693307a3587b16f0f18c487095f
|
|
| BLAKE2b-256 |
6b9b201a19df7563f4e0472c5ff9b6e5d900d76baaf6f1a98a621200c757ec75
|
File details
Details for the file pysubnet-2.2.0-py3-none-any.whl.
File metadata
- Download URL: pysubnet-2.2.0-py3-none-any.whl
- Upload date:
- Size: 36.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e323b4b4b44d4c67266d4dec8261e2e64b5be65dddb991ec45a68ccbbb4656a
|
|
| MD5 |
9b9c2ca245fcd5e06a02229b26773540
|
|
| BLAKE2b-256 |
56cd2a4607da660ffe6fb4e548b78406c19a224744fd639c0aa34795b5fe10b7
|