Skip to main content

Ethernity Cloud SDK Python

Project description

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.

  • Run: To run the project, run:

    python src/ethernity_task.py
    

    command to start the demo application and test the integration.

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.

Project 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.2.45.tar.gz (74.0 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.2.45-py3-none-any.whl (91.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ethernity_cloud_sdk_py-0.2.45.tar.gz
Algorithm Hash digest
SHA256 8437a5ce1c843f308e2c2e58253c4e76eae4fd1b45906c82de0404c2267e8fa7
MD5 f0be036a5a0791443bb10e71408bc3db
BLAKE2b-256 400e74f8f0735d804d90b82b931ee68627ca64c8180ddbc084d979bcbab99ebd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ethernity_cloud_sdk_py-0.2.45-py3-none-any.whl
Algorithm Hash digest
SHA256 9c3814905a08542acedda55ae96b479f08450bea3259ab995ef95357a90314da
MD5 3072782fbc3af409200dbf5b08c37138
BLAKE2b-256 6b40ef7db193035b51c02af9240552c1c8b0f9f55dfa757a5800ec3af6eabe45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page