Library for interfacing with a Substrate node
Maintained. Last release 4 days ago, commits in 2 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install substrate-interfacePython Substrate Interface
Description
This library specializes in interfacing with a Substrate node; querying storage, composing extrinsics, SCALE encoding/decoding and providing additional convenience methods to deal with the features and metadata of the Substrate runtime.
Documentation
Installation
Requires CPython 3.11 or newer. The test matrix covers 3.11 through 3.15.
python -m pip install substrate-interface
Python 3.15 may need to build native dependencies from source. Install the Rust toolchain and enable PyO3's stable ABI when no compatible wheels are available.
PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 python -m pip install substrate-interface
Initialization
Using embedded light client
substrate = SubstrateInterface(chainspec="polkadot_asset_hub", relay_chainspecs=["polkadot"])
Using node RPC endpoint
substrate = SubstrateInterface(url="ws://127.0.0.1:9944")
After connecting certain properties like ss58_format will be determined automatically by querying the RPC node. At
the moment this will work for most MetadataV14 and above runtimes like Polkadot, Kusama, Acala, Moonbeam. For
older or runtimes under development the (default 42) and other properties should be set manually.