Skip to main content

Python light client for Polkadot/Substrate via smoldot

Project description

pypolkadot

Experimental Python light client for Polkadot/Substrate via smoldot.

Connect to Polkadot blockchains trustlessly - no full node, no RPC provider needed.

This is a feasibility demonstrator to integrate the functionality in https://github.com/JAMdotTech/py-polkadot-sdk.

Installation

pip install pypolkadot

Quick Start

from pypolkadot import LightClient

# Connect to Polkadot mainnet (embedded light client)
client = LightClient()

# Query storage
total = client.storage("Balances", "TotalIssuance")
print(f"Total issuance: {total}")

# Get events
for event in client.events(pallet="System"):
    print(f"{event.pallet}.{event.name}")

# Subscribe to blocks
for block in client.subscribe_finalized():
    print(f"Block #{block.number}: {block.hash}")

Features

  • Verifies proofs cryptographically, no RPC trust required
  • Light client runs in-process, no external dependencies
  • Query any storage/events without codegen
  • Simple Python API, no async/await required

API

Method Description
LightClient() Connect to Polkadot mainnet
LightClient(testnet=True) Connect to Polkadot mainnet
LightClient.from_chain_spec(json) Connect with custom chain spec
client.storage(pallet, entry, keys) Query storage
client.events(block_hash, pallet, name) Get/filter events
client.submit(signed_hex) Submit pre-signed extrinsic
client.subscribe_finalized() Stream finalized blocks

Development

# Setup
uv venv && source .venv/bin/activate
pip install maturin

# Build
maturin develop

# Test
python tests/test_storage.py

License

GPL-3.0 as intended.

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

pypolkadot-0.2.0.tar.gz (568.1 kB view details)

Uploaded Source

Built Distribution

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

pypolkadot-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file pypolkadot-0.2.0.tar.gz.

File metadata

  • Download URL: pypolkadot-0.2.0.tar.gz
  • Upload date:
  • Size: 568.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for pypolkadot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4deb04d521ab8cdd40ebbfad8ab4d9b25b220a4844f917686cee39c0f786451c
MD5 fa1bbcf2ff8153fc658353af2f8324d6
BLAKE2b-256 3c9fc5ef528411c3af1b28f61b6025a3c71caf622ff1c7d0552895fc0ece3f53

See more details on using hashes here.

File details

Details for the file pypolkadot-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pypolkadot-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ba190932509d362df16b19cc4ddd129be10f0d545d0cf3a675f5a967332c3b0
MD5 8601a03b5625733df21339fdcd512218
BLAKE2b-256 53b27b006436bc5646f0791a68499a214c6ba57313c3df43937d45176327ecfd

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