|
1 |
| -This is a modernised version of the py-substrate-interface library, with the ability to use it asynchronously (as well as synchronously). It aims to be almost fully API-compatible with the original library. |
| 1 | +# Async Substrate Interface |
| 2 | +This project provides an asynchronous interface for interacting with [Substrate](https://substrate.io/)-based blockchains. It is based on the [py-substrate-interface](https://github.com/polkascan/py-substrate-interface) project. |
2 | 3 |
|
3 |
| -In addition to it's async nature, it is additionally improved with using bt-decode rather than py-scale-codec for significantly faster SCALE decoding. |
| 4 | +Additionally, this project uses [bt-decode](https://github.com/opentensor/bt-decode) instead of [py-scale-codec](https://github.com/polkascan/py-scale-codec) for faster [SCALE](https://docs.substrate.io/reference/scale-codec/) decoding. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +To install the package, use the following command: |
| 9 | + |
| 10 | +```bash |
| 11 | +pip install async-substrate-interface |
| 12 | +``` |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +Here are examples of how to use the sync and async inferfaces: |
| 17 | + |
| 18 | +```python |
| 19 | +from async_substrate_interface import SubstrateInterface |
| 20 | + |
| 21 | +def main(): |
| 22 | + substrate = SubstrateInterface( |
| 23 | + url="wss://rpc.polkadot.io" |
| 24 | + ) |
| 25 | + with substrate: |
| 26 | + result = substrate.query( |
| 27 | + module='System', |
| 28 | + storage_function='Account', |
| 29 | + params=['5CZs3T15Ky4jch1sUpSFwkUbYEnsCfe1WCY51fH3SPV6NFnf'] |
| 30 | + ) |
| 31 | + |
| 32 | + print(result) |
| 33 | + |
| 34 | +main() |
| 35 | +``` |
| 36 | + |
| 37 | +```python |
| 38 | +import asyncio |
| 39 | +from async_substrate_interface import AsyncSubstrateInterface |
| 40 | + |
| 41 | +async def main(): |
| 42 | + substrate = AsyncSubstrateInterface( |
| 43 | + url="wss://rpc.polkadot.io" |
| 44 | + ) |
| 45 | + async with substrate: |
| 46 | + result = await substrate.query( |
| 47 | + module='System', |
| 48 | + storage_function='Account', |
| 49 | + params=['5CZs3T15Ky4jch1sUpSFwkUbYEnsCfe1WCY51fH3SPV6NFnf'] |
| 50 | + ) |
| 51 | + |
| 52 | + print(result) |
| 53 | + |
| 54 | +asyncio.run(main()) |
| 55 | +``` |
| 56 | + |
| 57 | +## Contributing |
| 58 | + |
| 59 | +Contributions are welcome! Please open an issue or submit a pull request to the `staging` branch. |
| 60 | + |
| 61 | +## License |
| 62 | + |
| 63 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 64 | + |
| 65 | +## Contact |
| 66 | + |
| 67 | +For any questions or inquiries, please join the Bittensor Development Discord server: [Church of Rao](https://discord.gg/XC7ucQmq2Q). |
0 commit comments