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)
  • ๐Ÿƒโ€โ™‚๏ธ 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

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.0.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.0.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file pysubnet-2.0.0.tar.gz.

File metadata

  • Download URL: pysubnet-2.0.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.0.0.tar.gz
Algorithm Hash digest
SHA256 90f83824c3452007626b3a060348efd37ebe5d1e8147f7548e517b458f25fba3
MD5 a23b63a692211d9c9698672351fa860a
BLAKE2b-256 02f88ac8cd087106a9b0c4eb2555a93f593b77f52d73d7c86387580175ba606d

See more details on using hashes here.

File details

Details for the file pysubnet-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pysubnet-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb72d78cb4f6712f29f6d2618e442562efa817aba9b8576c28d97c389564a2c8
MD5 d38ad0886ea73d86dfaca6b010c95b1f
BLAKE2b-256 bf208cde0af001f54e5d081968d13c8c872c6f8fc90245c9fc6fb3883fe08380

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