Skip to main content

SDK package for zelluar sequencer

Project description

zellular.py

A Python SDK for interacting with the Zellular network.

Dependencies

To use zelluar.py, you'll need to install the MCL native library. Follow these steps to install it:

$ sudo apt install libgmp3-dev
$ wget https://github.com/herumi/mcl/archive/refs/tags/v1.93.zip
$ unzip v1.93.zip
$ cd mcl-1.93
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install

Installation

Install the zelluar.py package via pip:

pip install zellular

Usage

Getting Nodes

Zellular Testnet is deployed on the EigenLayer Holesky network. You can query the list of nodes using the following code:

from pprint import pprint
import zellular

operators = zellular.get_operators()
pprint(operators)

Example output:

{'0x3eaa...078c': {
    'id': '0x3eaa...078c',
    'operatorId': '0xfd17...97fd',
    'pubkeyG1_X': '1313...2753',
    'pubkeyG1_Y': '1144...6864',
    'pubkeyG2_X': ['1051...8501', '1562...5720'],
    'pubkeyG2_Y': ['1601...1108', '1448...1899'],
    'public_key_g2': <eigensdk.crypto.bls.attestation.G2Point object at 0x7d8f31b167d0>,
    'socket': 'http://5.161.230.186:6001',
    'stake': 1
}, ... }

[!TIP] The node URL of each operator can be accessed using operator["socket"].

Posting Transactions

Zellular sequences transactions in batches. You can send a batch of transactions like this:

import requests
from uuid import uuid4
import time
from zellular import Zellular

base_url = "http://5.161.230.186:6001"
app_name = "simple_app"

zellular = Zellular(app_name, base_url)

t = int(time.time())
txs = [{"operation": "foo", "tx_id": str(uuid4()), "t": t} for _ in range(5)]

index = zellular.send(txs, blocking=True)

When setting blocking=True, the method waits for the batch to be sequenced and returns the index.

[!TIP] You can add your app to zellular test network using: curl -X POST https://www.zellular.xyz/testnet/apps -H "Content-Type: application/json" -d '{"app_name": "your-app-name"}'

Fetching and Verifying Transactions

Unlike reading from a traditional blockchain, where you must trust the node you're connected to, Zellular allows trustless reading of sequenced transactions. This is achieved through an aggregated BLS signature that verifies if the sequence of transaction batches is approved by the majority of Zellular nodes. The Zellular SDK abstracts the complexities of verifying these signatures, providing a simple way to constantly pull the latest finalized transaction batches:

import json
from zellular import Zellular

base_url = "http://5.161.230.186:6001"
app_name = "simple_app"

zellular = Zellular(app_name, base_url)

for batch, index in zellular.batches(after=0):
    txs = json.loads(batch)
    for i, tx in enumerate(txs):
        print(index, i, tx)

Example output:

app: simple_app, index: 1, result: True
app: simple_app, index: 2, result: True
583 0 {'tx_id': '7eaa...2101', 'operation': 'foo', 't': 1725363009}
583 1 {'tx_id': '5839...6f5e', 'operation': 'foo', 't': 1725363009}
583 2 {'tx_id': '0a1a...05cb', 'operation': 'foo', 't': 1725363009}
583 3 {'tx_id': '6339...cc08', 'operation': 'foo', 't': 1725363009}
583 4 {'tx_id': 'cf4a...fc19', 'operation': 'foo', 't': 1725363009}
...

If you want to start reading batches from the latest finalized batch rather than from the beginning, you can achieve this by specifying the after parameter with the latest index. Here’s an example of how to do this:

index = zellular.get_last_finalized()["index"]
for batch, index in zellular.batches(after=index):
    ...

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

zellular-0.1.7.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

zellular-0.1.7-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file zellular-0.1.7.tar.gz.

File metadata

  • Download URL: zellular-0.1.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for zellular-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a50c0b7692b09a82db5fb9dd08ac11313e66a969d9f2c3c303d9860d0e8e40fb
MD5 1af92065a299c926713f3cd8add57d78
BLAKE2b-256 47bb4d4d64638a59a38d73c9a33e3dfcc18783fa18262150f01a7797a2da921f

See more details on using hashes here.

File details

Details for the file zellular-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: zellular-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for zellular-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c0a5482c782a4a527195f0a10413fef235c5c296d73f1642baf49e70605c0318
MD5 27d4b98d318c51b84c4a7bf0751d9762
BLAKE2b-256 5347ead2b6f0dcadfb4886a1687f2ddc8b22fd2b46bca35d69a15ed90f5fa7c6

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