substrate-interface


Namesubstrate-interface JSON
Version 1.7.8 PyPI version JSON
download
home_pagehttps://github.com/polkascan/py-substrate-interface
SummaryLibrary for interfacing with a Substrate node
upload_time2024-04-11 14:18:14
maintainerNone
docs_urlNone
authorStichting Polkascan (Polkascan Foundation)
requires_python<4,>=3.7
licenseNone
keywords interface polkascan polkadot substrate blockchain rpc kusama
VCS
bugtrack_url
requirements websocket-client base58 certifi idna requests xxhash pytest ecdsa eth-keys eth_utils pycryptodome PyNaCl scalecodec py-sr25519-bindings py-ed25519-zebra-bindings py-bip39-bindings mkdocs mkdocs-material mkdocs-autorefs mkdocstrings mkdocstrings
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Substrate Interface

[![Build Status](https://img.shields.io/github/actions/workflow/status/polkascan/py-substrate-interface/unittests.yml?branch=master)](https://github.com/polkascan/py-substrate-interface/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/polkascan/py-substrate-interface/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://polkascan.github.io/py-substrate-interface/)
* [Metadata documentation for Polkadot and Kusama ecosystem runtimes](https://polkascan.github.io/py-substrate-metadata-docs/)

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

## Initialization

```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), [Github Discussions](https://github.com/polkascan/py-substrate-interface/discussions) or 
reach out to us on our [matrix](http://matrix.org) chat group: [Polkascan Technical](https://matrix.to/#/#polkascan:matrix.org).

## License
https://github.com/polkascan/py-substrate-interface/blob/master/LICENSE



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/polkascan/py-substrate-interface",
    "name": "substrate-interface",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.7",
    "maintainer_email": null,
    "keywords": "interface polkascan polkadot substrate blockchain rpc kusama",
    "author": "Stichting Polkascan (Polkascan Foundation)",
    "author_email": "info@polkascan.org",
    "download_url": "https://files.pythonhosted.org/packages/d6/56/a9f2b989e0801e7e34b3dd802449c7d950ebe21598ec0a01f8bdd2a909dd/substrate-interface-1.7.8.tar.gz",
    "platform": null,
    "description": "# Python Substrate Interface\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/polkascan/py-substrate-interface/unittests.yml?branch=master)](https://github.com/polkascan/py-substrate-interface/actions?query=workflow%3A%22Run+unit+tests%22)\n[![Latest Version](https://img.shields.io/pypi/v/substrate-interface.svg)](https://pypi.org/project/substrate-interface/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/substrate-interface.svg)](https://pypi.org/project/substrate-interface/)\n[![License](https://img.shields.io/pypi/l/substrate-interface.svg)](https://github.com/polkascan/py-substrate-interface/blob/master/LICENSE)\n\n\n## Description\nThis library specializes in interfacing with a [Substrate](https://substrate.io/) node; querying storage, composing extrinsics, \nSCALE encoding/decoding and providing additional convenience methods to deal with the features and metadata of \nthe Substrate runtime.\n\n## Documentation\n\n* [Library documentation](https://polkascan.github.io/py-substrate-interface/)\n* [Metadata documentation for Polkadot and Kusama ecosystem runtimes](https://polkascan.github.io/py-substrate-metadata-docs/)\n\n## Installation\n```bash\npip install substrate-interface\n```\n\n## Initialization\n\n```python\nsubstrate = SubstrateInterface(url=\"ws://127.0.0.1:9944\")\n```\n\nAfter connecting certain properties like `ss58_format` will be determined automatically by querying the RPC node. At \nthe moment this will work for most `MetadataV14` and above runtimes like Polkadot, Kusama, Acala, Moonbeam. For \nolder or runtimes under development the `ss58_format` (default 42) and other properties should be set manually. \n\n## Quick usage\n\n### Balance information of an account\n```python\nresult = substrate.query('System', 'Account', ['F4xQKRUagnSGjFqafyhajLs94e7Vvzvr8ebwYJceKpr8R7T'])\nprint(result.value['data']['free']) # 635278638077956496\n```\n### Create balance transfer extrinsic\n\n```python\ncall = substrate.compose_call(\n    call_module='Balances',\n    call_function='transfer',\n    call_params={\n        'dest': '5E9oDs9PjpsBbxXxRE9uMaZZhnBAV38n2ouLB28oecBDdeQo',\n        'value': 1 * 10**12\n    }\n)\n\nkeypair = Keypair.create_from_uri('//Alice')\nextrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)\n\nreceipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)\n\nprint(f\"Extrinsic '{receipt.extrinsic_hash}' sent and included in block '{receipt.block_hash}'\")\n```\n\n## Contact and Support \n\nFor questions, please see the [Substrate StackExchange](https://substrate.stackexchange.com/questions/tagged/python), [Github Discussions](https://github.com/polkascan/py-substrate-interface/discussions) or \nreach out to us on our [matrix](http://matrix.org) chat group: [Polkascan Technical](https://matrix.to/#/#polkascan:matrix.org).\n\n## License\nhttps://github.com/polkascan/py-substrate-interface/blob/master/LICENSE\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Library for interfacing with a Substrate node",
    "version": "1.7.8",
    "project_urls": {
        "Homepage": "https://github.com/polkascan/py-substrate-interface"
    },
    "split_keywords": [
        "interface",
        "polkascan",
        "polkadot",
        "substrate",
        "blockchain",
        "rpc",
        "kusama"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aaae1165f8cfc3178fec168cc3967ffcdd6ee2be8e3311e73a6291a250f2cef0",
                "md5": "1db1b9afb4ee4541f89f2040727f77e6",
                "sha256": "90917f1ad435a11b2562577bbc5dd5d5970744287d8fc2b23b75780d682284e7"
            },
            "downloads": -1,
            "filename": "substrate_interface-1.7.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1db1b9afb4ee4541f89f2040727f77e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.7",
            "size": 59958,
            "upload_time": "2024-04-11T14:18:11",
            "upload_time_iso_8601": "2024-04-11T14:18:11.336107Z",
            "url": "https://files.pythonhosted.org/packages/aa/ae/1165f8cfc3178fec168cc3967ffcdd6ee2be8e3311e73a6291a250f2cef0/substrate_interface-1.7.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d656a9f2b989e0801e7e34b3dd802449c7d950ebe21598ec0a01f8bdd2a909dd",
                "md5": "623476c28419677ca2ed7946dcba5a98",
                "sha256": "9a8e21f18db8ce5bb117e2343028fd9f7eebfab6f1e12b05f13075a5d90d6ed5"
            },
            "downloads": -1,
            "filename": "substrate-interface-1.7.8.tar.gz",
            "has_sig": false,
            "md5_digest": "623476c28419677ca2ed7946dcba5a98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.7",
            "size": 79956,
            "upload_time": "2024-04-11T14:18:14",
            "upload_time_iso_8601": "2024-04-11T14:18:14.662342Z",
            "url": "https://files.pythonhosted.org/packages/d6/56/a9f2b989e0801e7e34b3dd802449c7d950ebe21598ec0a01f8bdd2a909dd/substrate-interface-1.7.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-11 14:18:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "polkascan",
    "github_project": "py-substrate-interface",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "websocket-client",
            "specs": [
                [
                    ">=",
                    "0.57.0"
                ],
                [
                    "<",
                    "2"
                ]
            ]
        },
        {
            "name": "base58",
            "specs": [
                [
                    "<",
                    "3"
                ],
                [
                    ">=",
                    "1.0.3"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    ">=",
                    "2019.3.9"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    ">=",
                    "2.1.0"
                ],
                [
                    "<",
                    "4"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.21.0"
                ],
                [
                    "<",
                    "3"
                ]
            ]
        },
        {
            "name": "xxhash",
            "specs": [
                [
                    ">=",
                    "1.3.0"
                ],
                [
                    "<",
                    "4"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "4.4.0"
                ]
            ]
        },
        {
            "name": "ecdsa",
            "specs": [
                [
                    "<",
                    "1"
                ],
                [
                    ">=",
                    "0.17.0"
                ]
            ]
        },
        {
            "name": "eth-keys",
            "specs": [
                [
                    ">=",
                    "0.2.1"
                ],
                [
                    "<",
                    "1"
                ]
            ]
        },
        {
            "name": "eth_utils",
            "specs": [
                [
                    "<",
                    "3"
                ],
                [
                    ">=",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "pycryptodome",
            "specs": [
                [
                    ">=",
                    "3.11.0"
                ],
                [
                    "<",
                    "4"
                ]
            ]
        },
        {
            "name": "PyNaCl",
            "specs": [
                [
                    "<",
                    "2"
                ],
                [
                    ">=",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "scalecodec",
            "specs": [
                [
                    ">=",
                    "1.2.8"
                ],
                [
                    "<",
                    "1.3"
                ]
            ]
        },
        {
            "name": "py-sr25519-bindings",
            "specs": [
                [
                    ">=",
                    "0.2.0"
                ],
                [
                    "<",
                    "1"
                ]
            ]
        },
        {
            "name": "py-ed25519-zebra-bindings",
            "specs": [
                [
                    "<",
                    "2"
                ],
                [
                    ">=",
                    "1.0"
                ]
            ]
        },
        {
            "name": "py-bip39-bindings",
            "specs": [
                [
                    ">=",
                    "0.1.9"
                ],
                [
                    "<",
                    "1"
                ]
            ]
        },
        {
            "name": "mkdocs",
            "specs": []
        },
        {
            "name": "mkdocs-material",
            "specs": []
        },
        {
            "name": "mkdocs-autorefs",
            "specs": []
        },
        {
            "name": "mkdocstrings",
            "specs": []
        },
        {
            "name": "mkdocstrings",
            "specs": []
        }
    ],
    "lcname": "substrate-interface"
}
        
Elapsed time: 0.27575s