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
- Clone the repo
git clone --recurse-submodules https://github.com/skalenetwork/skale-contracts.git && cd skale-contracts
- Install dependencies
cd python && pip install -e . && pip3 install -r scripts/requirements.txt && pip3 install -r tests/requirements.txt
Running tests (python)
-
set ENDPOINT environment variable using either option:
export ENDPOINT="http://my.mainnet.endpoint/my-api-key"
or
echo 'ENDPOINT="http://my.mainnet.endpoint/my-api-key"' > .env
-
run tests
pytest -v
- 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.0.dev5173083273881978081
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| skale_contracts-2.0.0.dev5173083273881978081.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| skale_contracts-2.0.0.dev5173083273881978081-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.8 kB
Release files / skale_contracts-2.0.0.dev5173083273881978081.tar.gz
| Download URL | skale_contracts-2.0.0.dev5173083273881978081.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc3c9de3f871ef2483b812411dcda8b814fde6edfa74e04cfb8f9410678df87c
|
|
BLAKE2b-256 checksum How to use checksums |
88dd29ecd1280fab6594fbb4cbf689193b3cba52aac5d1011bd05076805f7e61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / skale_contracts-2.0.0.dev5173083273881978081-py3-none-any.whl
| Download URL | skale_contracts-2.0.0.dev5173083273881978081-py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b63f17067a019d4a4f4d3d051996d5dcde7a281cc55760bec747fc1053955a82
|
|
BLAKE2b-256 checksum How to use checksums |
d00db06abfd5076153b1d64e6d8f4e6afa0b4f507211a545d100223c1bf15b9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|