Skip to main content

The Python client for working with the Celestia blockchain platform.

Project description

pylestia

This module provides a Python interface for interacting with the Celestia Node API. All methods communicate with the API via JSON-RPC, offering a flexible and developer-friendly solution for integrating Celestia functionality into applications.

It is designed for developers who want to interact with the Celestia network without dealing with the complexities of low-level RPC request handling.

Getting Started

Please see our Quick Start Guide to get up and running with pylestia!

We also have example code to help you integrate pylestia into your projects.

Compatibility

IMPORTANT: This library is ONLY compatible with celestia-types v0.11.0 and later. It is NOT backward compatible with earlier versions.

Built exclusively for celestia-types v0.11.0+, supporting:

  • Blob signer information (Share Version 1)
  • Improved error handling for blob submission
  • Public ShareProof fields
  • Updated commitment formats

This library requires celestia-types v0.11.0 and is designed to work with the latest Celestia node versions.

🚀 Installation

Recommended: Using Poetry

# Add pylestia to your project dependencies
poetry add pylestia

# Or specify a specific version
poetry add pylestia==0.2.0

Alternative: Using pip

pip install pylestia

🔧 Usage

Connecting to Celestia Node

Below is an example of how to connect to a real Celestia node using its RPC endpoint.

from pylestia import Client

# Configuration for connecting to a Celestia node
node_url = "https://celestia-rpc.example.com"  # Replace with the actual RPC node URL
auth_token = "your-auth-token"  # Replace with your authentication token (if required)

# Initialize the client
client = Client(base_url=node_url)

# Example usage of the API
async with client.connect(auth_token) as api:
    balance = await api.state.balance()

Custom Deserialization Example

from pydantic import BaseModel

class CustomBalanceModel(BaseModel):
    amount: int
    denom: str

async with client.connect(auth_token) as api:
    # The `deserializer` parameter allows you to transform raw API data into a desired format
    last_height = await api.header.local_head(deserializer=lambda data: int(data['header']['height']))
    isinstance(last_height, int) # True
    # Use the Pydantic model to validate and transform the balance response
    balance = await api.state.balance(deserializer=CustomBalanceModel.model_validate)
    isinstance(balance.amount, int) # True

Contributing

Prerequisites

For those interested in contributing to pylestia:

# Clone the repository
git clone https://github.com/Bidon15/pylestia.git
cd pylestia

# Install dependencies with Poetry
poetry install

# Run Python-only tests (don't require Rust compilation)
poetry run pytest tests/test_models.py tests/test_blob_signer.py tests/test_python_only.py

# For full testing including Rust extensions
pip install maturin
maturin develop
poetry run pytest

Building from Source

pylestia contains Rust extensions, so you'll need:

  1. Rust and Cargo installed
  2. A supported Python version (3.10+)

To build the package:

# Install maturin if you don't have it
pip install maturin

# Build the package (will compile Rust code)
maturin build --release

# The built package can be installed with
pip install target/wheels/pylestia-0.2.0-*.whl

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

pylestia-0.2.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

pylestia-0.2.0-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file pylestia-0.2.0.tar.gz.

File metadata

  • Download URL: pylestia-0.2.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for pylestia-0.2.0.tar.gz
Algorithm Hash digest
SHA256 027cd1f0a04d182f5684e0b28cea318f99c564da2632f19f77af44ff2befc912
MD5 ed66dfebcc1894221ad8e92621ffb56e
BLAKE2b-256 e7093977cb45ace20ae90c29ba30ba6ea9898e5088b03c3f867d15ca9aa252f5

See more details on using hashes here.

File details

Details for the file pylestia-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pylestia-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for pylestia-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 975c9d60d4352511e23e9f870772c3fa1874bd0274671dde5a262032586f5bce
MD5 89eddb526be01a615ca38f9e7e786334
BLAKE2b-256 ed56b52f18a5f820d0cbdb1ed6a531c07a6b54155bf5019da761de6e4ab186b6

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