Metadata-Version: 2.4
Name: skale.py
Version: 7.6.dev2
Summary: SKALE client tools
Project-URL: Homepage, https://github.com/skalenetwork/skale.py
Author-email: SKALE Labs <support@skalelabs.com>
License: AGPL-3.0-or-later
License-File: LICENSE
Keywords: skale
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.11
Requires-Python: <4,>=3.11
Requires-Dist: redis==6.4.0
Requires-Dist: sgx-py==0.11dev0
Requires-Dist: skale-contracts==2.0.0a6
Requires-Dist: typing-extensions==4.15.0
Requires-Dist: web3==7.13.0
Provides-Extra: dev
Requires-Dist: click==8.3.0; extra == 'dev'
Requires-Dist: codecov; extra == 'dev'
Requires-Dist: freezegun==1.5.5; extra == 'dev'
Requires-Dist: importlib-metadata<9.0; extra == 'dev'
Requires-Dist: isort<5.4.3,>=4.2.15; extra == 'dev'
Requires-Dist: ledgerblue==0.1.55; extra == 'dev'
Requires-Dist: mock==5.2.0; extra == 'dev'
Requires-Dist: mypy==1.18.2; extra == 'dev'
Requires-Dist: pytest-cov==7.0.0; extra == 'dev'
Requires-Dist: pytest==8.4.2; extra == 'dev'
Requires-Dist: ruff==0.14.0; extra == 'dev'
Requires-Dist: types-redis; extra == 'dev'
Requires-Dist: types-requests; extra == 'dev'
Provides-Extra: hw-wallet
Requires-Dist: ledgerblue==0.1.55; extra == 'hw-wallet'
Provides-Extra: linter
Requires-Dist: importlib-metadata<9.0; extra == 'linter'
Requires-Dist: isort<5.4.3,>=4.2.15; extra == 'linter'
Requires-Dist: mypy==1.18.2; extra == 'linter'
Requires-Dist: ruff==0.14.0; extra == 'linter'
Description-Content-Type: text/markdown

# skale.py

[![PyPI version](https://badge.fury.io/py/skale.py.svg)](https://badge.fury.io/py/skale.py)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/skalenetwork/skale.py/Test)
[![codecov](https://codecov.io/gh/skalenetwork/skale.py/branch/develop/graph/badge.svg?token=XHiZ15ijpa)](https://codecov.io/gh/skalenetwork/skale.py)
![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/skalenetwork/skale.py)
[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)

Python client library used in SKALE network components.

* Python 3.11+ support
* Compatibility with `web3.py` v7

### Installation

```bash
pip install skale.py
```

### Usage

#### Supported wallets

* Ledger Wallet (works with Ledger Nano S and other models)
* RPC Wallet (works with [SKALE Transactions Manager](https://github.com/skalenetwork/transactions-manager))
* SGX Wallet (works with [SKALE SGX Wallet](https://github.com/skalenetwork/sgxwallet))
* Web3 Wallet (works with `web3.py` providers and private keys in memory)

#### Library initialization

With Web3Wallet (private key in memory):

```python
from skale import SkaleManager
from skale.wallets import Web3Wallet
from skale.utils.web3_utils import init_web3

web3 = init_web3(ENDPOINT)
wallet = Web3Wallet(private_key, web3)
skale = Skale(ENDPOINT, ABI_FILEPATH, wallet)
```

With external transactions manager:

```python
from skale import SkaleManager
from skale.wallets import RPCWallet

web3 = init_web3(ENDPOINT)
wallet = RPCWallet(TM_URL)
skale = Skale(ENDPOINT, ABI_FILEPATH, wallet)
```

Interactions with SKALE contracts

```python
active_nodes = skale.nodes.get_active_node_ips()
schains = skale.schains.get_schains_for_owner('0x...')
```

#### Working in multiple threads

Due to the web3.py v5 limitations you have to create separate instances of the skale.py for the each thread.\
Take a look on the `tests/multithreading_test.py` for the reference.

### Development

##### Add pre-commit hook:

```bash
nano .git/hooks/pre-commit
```

```bash
uv run ruff check skale/
uv run mypy skale/
```

##### Install local version

```bash
uv sync --all-extras
```

##### Export environment variables

To export environment variables for running tests locally, run:

```bash
. ./scripts/export_env.sh
```

#### Build and publish library

```bash
bash build_and_publish.sh major/minor/patch
```

#### If you're using .env file

```bash
 export $(cat .env | xargs) && bash build_and_publish.sh major/minor/patch
```

#### Versioning

The version scheme for this repo is `{major}.{minor}.{patch}`
For more details see: <https://semver.org/>

### License

![GitHub](https://img.shields.io/github/license/skalenetwork/skale.py.svg)

All contributions are made under the [GNU Affero General Public License v3](https://www.gnu.org/licenses/agpl-3.0.en.html). See [LICENSE](LICENSE).
