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.1

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(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.1.tar.gz (25.7 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.1-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylestia-0.2.1.tar.gz
  • Upload date:
  • Size: 25.7 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.1.tar.gz
Algorithm Hash digest
SHA256 987014a5759fa741e652b2b00fe7bce84dad0a80398a1160691fb1c9c753b936
MD5 ede0d2d86076ecbd37da770ef0f62eac
BLAKE2b-256 d3a2a80463f60235c9d9b59dd0cef206eea24118d12e578b57fb864477b61489

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylestia-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 33.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a79d2a1d8a25a12438602729cbf70080d154b0c87f0877ef5a049d36a2a56272
MD5 cb6612abf41927304373efa5b73afc04
BLAKE2b-256 db875f9f60d0858712c910427053b2c73ce02cfa2f9c66c71db788eb8cf07ae6

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