Skip to main content

Ethernity Cloud logo

The Python implementation of the Ethernity CLOUD SDK protocol

Ethernity Cloud SDK PY

This project provides a set of tools and scripts to work with the Ethernity Cloud SDK in a python environment.

Table of Contents

Pre-requisites

Linux:

  • build-essentials
  • Python 3.10+
  • docker
  • docker-compose

Windows:

  • Python 3.13
  • Docker Desktop

Installation

To install the package and its dependencies, run:

python -m venv venv

source venv/bin/activate # for MacOS and Linux
venv\Scripts\activate # for Windows

pip install ethernity-cloud-sdk-py

Usage

After installation, you can use the provided scripts to build, publish, and initialize your project.

Operating System compatibility

The sdk has been tested on the following operating systems:

  • Windows 10
  • linux (Ubuntu 20.04)

Blockchain compatibility

  • Bloxberg:
    • Testnet - tested and working
    • Mainnet - to be provided during the following updates
  • Polyhon:
    • Amoy Testnet - to be provided during the following updates
    • Mainnet - to be provided during the following updates

Scripts

  • Initialize: To initialize the project, run:

    ecld-init
    

    at this step, all the initial configurations will be set up and the project will be ready to be built, published and run.

  • Build: To build the project, run:

    ecld-build
    

    the project will be built and the docker repository output will be stored in the registry/ directory. This is the stage where the backend functions are added to the secure images.

  • Publish: To publish the project, run:

    ecld-publish
    

    Required after build, to build and integrate the secure certificates that will be used during executions and to register the project to the Ethernity Cloud Image Register.

  • Test (local, no chain): To run your backend locally with the enclave's own executor — no SGX, no gas, instant — run:

    ecld-test 'hello("World")'
    ecld-test --file payload.py
    ecld-test --input data.json 'process(___etny_data_set___)'
    

    This validates the call (function names, arguments, result wiring) before a single on-chain request is paid for. If your dApp uses ESR (Enclave State Registry), state is emulated locally and on by default: StateRegistry get/commit, ownership/ACL, and task_caller() all work in-process against an in-memory registry, and persist between runs in .ecld-esr-local.*.json. The task caller defaults to your developer address; override it with --caller. ecld-test serve starts a local API so the runner's LOCAL mode drives your real integration end to end. Exit code 0 on SUCCESS, 1 otherwise.

  • Run (on the network): To submit a payload to the network and print the decrypted result, run:

    ecld-run 'hello("World")'
    ecld-run --file payload.py
    ecld-run --input data.json 'process(___etny_data_set___)'
    ecld-run --json 'esr_increment()'
    

    This is the network-side sibling of ecld-test: instead of executing locally it drives the runner end to end — encrypt → IPFS → on-chain request → wait for a node → download and decrypt the result. It costs gas and needs a funded key. Network and enclaves come from .config.json (BLOCKCHAIN_NETWORK, PROJECT_NAME, TRUSTED_ZONE_IMAGE), overridable with --network/--securelock/--trustedzone; the signing key is ECLD_PRIVATE_KEY (plaintext) or the encrypted ENC_PRIVATE_KEY unlocked with ECLD_KEY_PASSWORD (or an interactive prompt). Resources are tunable with --task-price/--cpu/--memory/--storage/--bandwidth/--duration/--validators. Exit code 0 on a SUCCESS task result, 1 otherwise. (python src/ethernity_task.py remains available as a scriptable template if you prefer driving the runner yourself.)

  • Inspect (read-only): To read enclave and on-chain diagnostics — network, trustedzone/securelock registration, and ESR state — without spending gas, run:

    ecld-info
    ecld-info esr state <key>
    

Usage

To use the SDK:

  • after installation, run ecld-init to initialize the project
  • in you workspace, you will find the scr/serverless directory, this contains a backend.py file. This file will be imported in the dApp images to provide the backend functions for calling from the frontend of your application, eg.:
def hello(msg='World'):
    return "Hello "+msg

From your py application, using the ethernity cloud runner library, you will be calling the function as seen in the below example, where we pass hello("World") to be executed on the backend which will run in the Blockchain:

import os
import sys
from dotenv import load_dotenv

load_dotenv()

from ethernity_cloud_runner_py.runner import EthernityCloudRunner  # type: ignore


def execute_task() -> None:
    ipfs_address = "https://ipfs.ethernity.cloud/api/v0"

    code = 'hello("Hello, Python World!")'

    runner = EthernityCloudRunner()
    runner.initialize_storage(ipfs_address)

    resources = {
        "taskPrice": 8,
        "cpu": 1,
        "memory": 1,
        "storage": 1,
        "bandwidth": 1,
        "duration": 1,
        "validators": 1,
    }
    # this will execute a new task using Python template and will run the code provided above
    # the code will run on the TESTNET network
    runner.run(
        os.getenv("PROJECT_NAME"),
        code,
        "0xd58f5C1834279ABD601df85b3E4b2323aDD4E75e",
        resources,
        os.getenv("TRUSTED_ZONE_IMAGE", ""),
    )


if __name__ == "__main__":
    execute_task()
  • you are able to define the functions needed to be used in the backend, while making sure that the function that is script is compilable and that it exports the function that will be called from the frontend, in the above example, the hello function.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ethernity_cloud_sdk_py-0.8.21.tar.gz (299.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ethernity_cloud_sdk_py-0.8.21-py3-none-any.whl (333.3 kB view details)

Uploaded Python 3

File details

Details for the file ethernity_cloud_sdk_py-0.8.21.tar.gz.

File metadata

  • Download URL: ethernity_cloud_sdk_py-0.8.21.tar.gz
  • Upload date:
  • Size: 299.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for ethernity_cloud_sdk_py-0.8.21.tar.gz
Algorithm Hash digest
SHA256 8ffa58904e783e1bc4e088bd3b9386d67348cb8d2dd8d61e50853d088881d553
MD5 ff43716d2009e102f1226bde1a76ca14
BLAKE2b-256 e3e6adb6327b347fd8b4bdfe2f6eaae12592af9ad96f9ac44241fa8a35fd8be9

See more details on using hashes here.

File details

Details for the file ethernity_cloud_sdk_py-0.8.21-py3-none-any.whl.

File metadata

File hashes

Hashes for ethernity_cloud_sdk_py-0.8.21-py3-none-any.whl
Algorithm Hash digest
SHA256 f9adc8592056616eccd3e3d8eecddb9e09391dc841ffc2ac209ea376ca805be6
MD5 2e7dab302f830bd14bbff782aa6e09a1
BLAKE2b-256 5d8f3a97e271539a14187ee99599cde0b638e12c51db48eb847cb8d49a0c0b59

See more details on using hashes here.

Release history Release notifications | RSS feed

0.8.31

2 files

0.8.30

2 files

0.8.29

2 files

0.8.28

2 files

0.8.27

2 files

0.8.26

2 files

0.8.25

2 files

0.8.24

2 files

0.8.23

2 files

0.8.22

2 files

This release

0.8.21 This release

2 files

0.8.20

2 files

0.8.19

2 files

0.8.18

2 files

0.8.17

2 files

0.8.15

2 files

0.8.14

2 files

0.8.13

2 files

0.8.12

2 files

0.8.11

2 files

0.8.10

2 files

0.8.9

2 files

0.8.8

2 files

0.8.7

2 files

0.8.6

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.3.29

2 files

0.3.28

2 files

0.3.27

2 files

0.3.26

2 files

0.3.25

2 files

0.3.24

2 files

0.3.23

2 files

0.3.22

2 files

0.3.21

2 files

0.3.20

2 files

0.3.19

2 files

0.3.18

2 files

0.3.17

2 files

0.3.16

2 files

0.3.15

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.46

2 files

0.2.45

2 files

0.2.43

2 files

0.2.42

2 files

0.2.41

2 files

0.2.40

2 files

0.2.39

2 files

0.2.38

2 files

0.2.37

2 files

0.2.36

2 files

0.2.35

2 files

0.2.34

2 files

0.2.33

2 files

0.2.32

2 files

0.2.31

2 files

0.2.30

2 files

0.2.29

2 files

0.2.28

2 files

0.2.27

2 files

0.2.26

2 files

0.2.25

2 files

0.2.24

2 files

0.2.23

2 files

0.2.22

2 files

0.2.21

2 files

0.2.20

2 files

0.2.19

2 files

0.2.18

2 files

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.39

2 files

0.1.38

2 files

0.1.37

2 files

0.1.36

2 files

0.1.35

2 files

0.1.34

2 files

0.1.33

2 files

0.1.32

1 file

0.1.31

2 files

0.1.30

2 files

0.1.29

2 files

0.1.28

2 files

0.1.27

2 files

0.1.14

2 files

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