Skip to main content

Deploy a substrate permissioned network using python

Project description

PySubnet

PyPI version Python 3.10+ License: Apache 2.0

The easiest way to /develop/deploy/test a multi-node substrate network

PySubnet


๐Ÿš€ 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysubnet-2.2.0.tar.gz (4.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysubnet-2.2.0-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

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

Hashes for pysubnet-2.2.0.tar.gz
Algorithm Hash digest
SHA256 4e8f515724d770e2f66df44b8dce28989e96a565e33f5e419f4977c73da41969
MD5 647c0693307a3587b16f0f18c487095f
BLAKE2b-256 6b9b201a19df7563f4e0472c5ff9b6e5d900d76baaf6f1a98a621200c757ec75

See more details on using hashes here.

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

Hashes for pysubnet-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e323b4b4b44d4c67266d4dec8261e2e64b5be65dddb991ec45a68ccbbb4656a
MD5 9b9c2ca245fcd5e06a02229b26773540
BLAKE2b-256 56cd2a4607da660ffe6fb4e548b78406c19a224744fd639c0aa34795b5fe10b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page