Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

SKALE Contracts Python

Description

The library simplifies development of dApps that interact with smart contracts in SKALE infrastructure using python.

Features

  • Resolving of addresses of SKALE contracts on different networks
  • Providing up to date ABI for SKALE contracts (they may change over time due to upgradeable nature of some contracts)
  • Automatic creation of Contract objects using web3
  • Supports web3 library versions >= 7, < 8

Importing the library

pip install skale-contracts

Setup repo locally

  1. Clone the repo
git clone --recurse-submodules https://github.com/skalenetwork/skale-contracts.git && cd skale-contracts
  1. Install dependencies
cd python && pip install -e . && pip3 install -r scripts/requirements.txt && pip3 install -r tests/requirements.txt

Running tests (python)

  1. optionally set ENDPOINT environment variable to override the default public mainnet node:

    export ENDPOINT="http://my.mainnet.endpoint/my-api-key"
    

    or

    echo 'ENDPOINT="http://my.mainnet.endpoint/my-api-key"' > .env
    
  2. run tests

pytest -v
  1. run tests with coverage report (optional)
pytest --cov=./ --cov-report=xml -v

The tests require reliable network connection as they will fetch information like: - stable versions of skale projects - deployed versions of skale projects - ABIs of smart-contracts - perform read operations to some deployed smart-contracts on Mainnet and SKALE's Europa-chain

Glossary

Main abstractions used by the library are provided below:

Network

Represents the blockchain where smart contracts are deployed.

It could be Ethereum mainnet, goerli, SKALE chain or similar ethereum compatible chain.

Project

SKALE set of smart contracts grouped into a project to serve a particular purpose.

Examples of projects are IMA, skale-manager or etherbase.

Instance

An instance represents a particular project deployed to a particular network.

For example IMA on Ethereum mainnet or etherbase on some of SKALE chains.

Alias

An alias is a textual name of an instance.

Usage

The library provides a master object skale_contracts.

This object is used to provide the desired network, project and instance using it's alias or direct address.

By instantiating a particular instance, it can be queried for information (address, ABI or Contract object) about a particular contract by it's name.

Usage Example

from web3 import HTTPProvider, Web3
from skale_contracts import skale_contracts
from skale_contracts.project_factory import SkaleProject, create_project
from skale_contracts.projects.skale_manager import SkaleManagerContract

# Any provider type that inherits from web3 BaseProvider
provider = Web3.HTTPProvider(MAINNET_ENDPOINT)
network = skale_contracts.get_network_by_provider(provider)
project = create_project(network, SkaleProject.SKALE_MANAGER)

# loading production instance of skale-manager deployed on ethereum mainnet
instance = project.get_instance('production')

# returns all contract names that can be queried using this instance
all_contract_names = instance.get_contract_names()

# get specific contract object
skale_manager_contract = instance.getContract(SkaleManagerContract.SKALE_MANAGER)

# will query the smart-contract. In this case, queries the version set in SkaleManager.sol
version = skale_manager_contract.functions.version().call()

Metadata

Release files for skale-contracts 2.0.0a17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skale-contracts 2.0.0a17
File Size Uploaded Provenance Actions
skale_contracts-2.0.0a17.tar.gz 16.1 kB Without provenance Details for skale_contracts-2.0.0a17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for skale-contracts 2.0.0a17
File Interpreter ABI Platform Actions
skale_contracts-2.0.0a17-py3-none-any.whl Python 3 none any Details for skale_contracts-2.0.0a17-py3-none-any.whl

Total release size: 42.6 kB

Release files / skale_contracts-2.0.0a17.tar.gz

Download URL skale_contracts-2.0.0a17.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
72eea2bf0419d0b403cfc9ec337d3b22b9121c28b7f5c00d1436c9d1eb9b7354
BLAKE2b-256 checksum
How to use checksums
c44785b14251f32b8aa1f10d3a6a58de0a2f42cfb38ac802ed69800d9012b792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / skale_contracts-2.0.0a17-py3-none-any.whl

Download URL skale_contracts-2.0.0a17-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c22969fdfa80ad83f3108004e1dce378aeace769e4d954f5de58e2f023be5eb9
BLAKE2b-256 checksum
How to use checksums
c156a40ca7b3a030acee2ef1d73388264e319b7de75ad6d4bed5aa83088afb57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.11.17

Security for skale-contracts 2.0.0a17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page