Skip to content

Easy multi-node substrate blockchain deployment for development and production. Forget about manually generating your chainspec for production. Define your network details in interactive mode or using a file and pysubnet will do the rest.

License

Notifications You must be signed in to change notification settings

weezy20/pysubnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PySubnet

PyPI version Python 3.10+ License: Apache 2.0

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:

  1. ๐ŸŸข PoA (Proof-of-Authority) - Perfect for learning and simple development
  2. ๐ŸŸก 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
  3. ๐Ÿ”ต BABE + GRANDPA - Production-ready consensus (like Polkadot)
  4. ๐ŸŸฃ BABE + GRANDPA + Staking - Full production setup with economic security
  5. ๐Ÿ”ด 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


  • 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/-c when 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

About

Easy multi-node substrate blockchain deployment for development and production. Forget about manually generating your chainspec for production. Define your network details in interactive mode or using a file and pysubnet will do the rest.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages