Python 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
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 ss58_format (default 42) and other properties should be set manually.
Quick usage
Balance information of an account
result = substrate.query('System', 'Account', ['F4xQKRUagnSGjFqafyhajLs94e7Vvzvr8ebwYJceKpr8R7T'])
print(result.value['data']['free']) # 635278638077956496
Create balance transfer extrinsic
call = substrate.compose_call(
call_module='Balances',
call_function='transfer',
call_params={
'dest': '5E9oDs9PjpsBbxXxRE9uMaZZhnBAV38n2ouLB28oecBDdeQo',
'value': 1 * 10**12
}
)
keypair = Keypair.create_from_uri('//Alice')
extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
print(f"Extrinsic '{receipt.extrinsic_hash}' sent and included in block '{receipt.block_hash}'")
Contact and Support
For questions, please see the Substrate StackExchange or Github Discussions.
License
https://github.com/JAMdotTech/py-polkadot-sdk/blob/master/LICENSE
Metadata
Release files for substrate-interface 1.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| substrate_interface-1.8.1.tar.gz | 1.5 MB | Without provenance | Details for substrate_interface-1.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| substrate_interface-1.8.1-py3-none-any.whl | Python 3 | none | any | Details for substrate_interface-1.8.1-py3-none-any.whl |
Total release size: 2.9 MB
Release files / substrate_interface-1.8.1.tar.gz
| Download URL | substrate_interface-1.8.1.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
821be590fa4f3d9bc731b4c370341b57cd98ef3419c81289cd369bdeefc008de
|
|
BLAKE2b-256 checksum How to use checksums |
c53fe1483635a892b84727187cf8ba8477a20e4036361202650a0bdb93eacf8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / substrate_interface-1.8.1-py3-none-any.whl
| Download URL | substrate_interface-1.8.1-py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07737b0dc86fb8962ec09c3518577556534f9ffa58ef1164fc70ffe8a5c54837
|
|
BLAKE2b-256 checksum How to use checksums |
c72ed6e2bb34473bfc8b6e915a21ee1a5dbf67c57dff8abea407e4e46cee5d83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for substrate-interface 1.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.