substrate-interface


Namesubstrate-interface JSON
Version 1.7.11 PyPI version JSON
download
home_pagehttps://github.com/polkascan/py-substrate-interface
SummaryLibrary for interfacing with a Substrate node
upload_time2024-10-07 20:37:11
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 No requirements were recorded.
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/7a/44/825433c906bdb69ab66fd3967c11fcfbcd953241e9d6257fd6a21c4cdc76/substrate-interface-1.7.11.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.11",
    "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": "56e137344b7acd260cbfed13563dcbab391c7c4b0c9eca5ec59aba138c5dca9e",
                "md5": "0f05e93903aa1e4ede308a069ee144eb",
                "sha256": "ce19bc97481769238ed23c752db985a3058637918693f2db6aeed2fab3756075"
            },
            "downloads": -1,
            "filename": "substrate_interface-1.7.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0f05e93903aa1e4ede308a069ee144eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.7",
            "size": 60273,
            "upload_time": "2024-10-07T20:37:10",
            "upload_time_iso_8601": "2024-10-07T20:37:10.123542Z",
            "url": "https://files.pythonhosted.org/packages/56/e1/37344b7acd260cbfed13563dcbab391c7c4b0c9eca5ec59aba138c5dca9e/substrate_interface-1.7.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a44825433c906bdb69ab66fd3967c11fcfbcd953241e9d6257fd6a21c4cdc76",
                "md5": "013155e93cf81e4d1d4fe4c7f2818de1",
                "sha256": "4caa5eacb9996edbe76ad12249521b3542bbd8d9d69b96734087201db1fef8f6"
            },
            "downloads": -1,
            "filename": "substrate-interface-1.7.11.tar.gz",
            "has_sig": false,
            "md5_digest": "013155e93cf81e4d1d4fe4c7f2818de1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.7",
            "size": 79221,
            "upload_time": "2024-10-07T20:37:11",
            "upload_time_iso_8601": "2024-10-07T20:37:11.986970Z",
            "url": "https://files.pythonhosted.org/packages/7a/44/825433c906bdb69ab66fd3967c11fcfbcd953241e9d6257fd6a21c4cdc76/substrate-interface-1.7.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-07 20:37:11",
    "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": [],
    "lcname": "substrate-interface"
}
        
Elapsed time: 0.70098s