Metadata-Version: 2.4
Name: substrate-interface
Version: 1.8.1
Summary: Library for interfacing with a Substrate node
Home-page: https://github.com/polkascan/py-substrate-interface
Author: Stichting Polkascan (Polkascan Foundation)
Author-email: info@polkascan.org
Keywords: interface polkascan polkadot substrate blockchain rpc kusama
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7, <4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: websocket-client<2,>=0.57.0
Requires-Dist: base58<3,>=1.0.3
Requires-Dist: certifi>=2019.3.9
Requires-Dist: idna<4,>=2.1.0
Requires-Dist: requests<3,>=2.21.0
Requires-Dist: xxhash<4,>=1.3.0
Requires-Dist: ecdsa<1,>=0.17.0
Requires-Dist: eth-keys<1,>=0.2.1
Requires-Dist: eth_utils<6,>=1.3.0
Requires-Dist: pycryptodome<4,>=3.11.0
Requires-Dist: PyNaCl<2,>=1.0.1
Requires-Dist: scalecodec<1.3,>=1.2.10
Requires-Dist: py-sr25519-bindings<1,>=0.2.0
Requires-Dist: py-ed25519-zebra-bindings<2,>=1.0
Requires-Dist: py-bip39-bindings<1,>=0.1.9
Requires-Dist: smoldot-light<1,>=0.1.0
Provides-Extra: test
Requires-Dist: coverage; extra == "test"
Requires-Dist: pytest; extra == "test"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Python Substrate Interface

[![Build Status](https://img.shields.io/github/actions/workflow/status/polkascan/py-substrate-interface/unittests.yml?branch=master)](https://github.com/JAMdotTech/py-polkadot-sdk/actions?query=workflow%3A%22Run+unit+tests%22)
[![Latest Version](https://img.shields.io/pypi/v/substrate-interface.svg)](https://pypi.org/project/substrate-interface/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/substrate-interface.svg)](https://pypi.org/project/substrate-interface/)
[![License](https://img.shields.io/pypi/l/substrate-interface.svg)](https://github.com/JAMdotTech/py-polkadot-sdk/blob/master/LICENSE)


## Description
This library specializes in interfacing with a [Substrate](https://substrate.io/) 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

* [Library documentation](https://jamdottech.github.io/py-polkadot-sdk/)
* [Metadata documentation for Polkadot and Kusama ecosystem runtimes](https://jamdottech.github.io/py-polkadot-metadata-docs/)

## Installation
```bash
pip install substrate-interface
```

## Initialization

Using embedded light client

```python
substrate = SubstrateInterface(chainspec="polkadot_asset_hub", relay_chainspecs=["polkadot"])
```

Using node RPC endpoint 
```python
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
```python
result = substrate.query('System', 'Account', ['F4xQKRUagnSGjFqafyhajLs94e7Vvzvr8ebwYJceKpr8R7T'])
print(result.value['data']['free']) # 635278638077956496
```
### Create balance transfer extrinsic

```python
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](https://substrate.stackexchange.com/questions/tagged/python) or [Github Discussions](https://github.com/JAMdotTech/py-polkadot-sdk/discussions).

## License
https://github.com/JAMdotTech/py-polkadot-sdk/blob/master/LICENSE
