Skip to content

If you like this project, please ⭐⭐⭐ it on GitHub!! Python library for interacting with SKALE Manager

License

Notifications You must be signed in to change notification settings

skalenetwork/skale.py

skale.py

PyPI version GitHub Workflow Status codecov Libraries.io dependency status for GitHub repo Discord

Python client library used in SKALE network components.

  • Python 3.7+ support
  • Compatibility with web3.py v6

Installation

pip install skale.py

Usage

Supported wallets

Library initialization

With embeded Web3Wallet

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:

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

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.

Code samples

You can find usage examples here.

Development

Add pre-commit hook:
nano .git/hooks/pre-commit
ruff check .
Install local version (with hot reload)
virtualenv venv
. venv/bin/activate 
pip install -e .[dev]

Build and publish library

bash build_and_publish.sh major/minor/patch

If you're using .env file

 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/

Testing

Run local ganache and deploy SKALE Manager:

MANAGER_TAG=... ETH_PRIVATE_KEY=... bash scripts/deploy_manager.sh

Running full test suite:

bash scripts/run_tests.sh

Running test suite manually:

See tests/README.md

License

GitHub

All contributions are made under the GNU Affero General Public License v3. See LICENSE.

About

If you like this project, please ⭐⭐⭐ it on GitHub!! Python library for interacting with SKALE Manager

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published