Skip to main content

Python SDK for interacting with the Xian blockchain

Project description

xian-py

xian-py is the Python SDK for talking to Xian nodes from applications, workers, automation jobs, and operator tooling.

Quick Start

Install the SDK:

pip install xian-tech-py

The published PyPI package name is xian-tech-py. The import package remains xian_py.

Read state and send a transaction:

from xian_py import Wallet, Xian

wallet = Wallet()

with Xian("http://127.0.0.1:26657") as client:
    balance = client.token().balance_of(wallet.public_key)
    receipt = client.token().transfer("bob", 5, wallet=wallet, mode="checktx")
    print(balance, receipt.code)

Watch indexed events from a BDS-enabled node:

import asyncio

from xian_py import XianAsync


async def main() -> None:
    async with XianAsync("http://127.0.0.1:26657") as client:
        async for event in client.token().transfers().watch(after_id=0):
            print(event.id, event.data)


asyncio.run(main())

Principles

  • The SDK keeps sync and async clients aligned so the same concepts work in scripts, services, and workers.
  • Transaction submission is explicit. Choose a broadcast mode deliberately instead of relying on hidden retry or blocking behavior.
  • Read models and projector loops belong in application code, but the SDK owns the repetitive plumbing for event polling, cursors, and decoding.
  • Reference apps and examples live in this repo because they demonstrate how to integrate Xian into Python systems, but they are not part of the published wheel.

Key Directories

  • src/xian_py/: clients, wallet helpers, transactions, models, and projector primitives
  • examples/: service, worker, and automation examples built on the SDK
  • tests/: SDK transport, decoding, and integration-shape coverage
  • docs/: repo-local notes such as compatibility and backlog items

What It Can Do

  • read current state from ABCI query paths and simulate readonly contract calls
  • retrieve the preferred contract source and the canonical runtime code separately
  • create, sign, and broadcast transactions with explicit async, checktx, and commit modes
  • wait for final receipts and work with typed transaction, event, block, and status models
  • query indexed blocks, transactions, events, state-history, and developer reward aggregates from BDS-backed nodes
  • watch blocks and indexed events with resumable cursors
  • use thin helper clients for common patterns such as contract, token, event, and state-key access
  • build SQLite-backed read models with the shared projector primitives

Indexed event/history queries and projector loops require a BDS-enabled node.

Core API Layers

  • Xian and XianAsync: the primary sync and async clients
  • client.contract(...), client.token(...), client.events(...), client.state_key(...): thin helper clients for common application patterns
  • typed models and error classes: predictable result handling instead of raw dictionaries everywhere
  • EventProjector, EventSource, SQLiteProjectionState: reusable polling/order/checkpoint primitives for local projections
  • Wallet: Ed25519 signing helper for Xian transactions

Typical Use Cases

  • backend APIs that read state and submit transactions
  • background workers that react to indexed events
  • automation jobs that reconcile or administer contracts
  • local projections that mirror chain activity into an application-owned SQLite read model
  • operator or integration scripts that need a clean Python surface over node RPCs and indexed queries

Optional extras:

pip install "xian-tech-py[app]"
pip install "xian-tech-py[eth]"
pip install "xian-tech-py[hd]"

Use the app extra for the included FastAPI-based examples.

Example Paths

Validation

uv sync --group dev
uv run ruff check .
uv run ruff format --check .
uv run pytest

Related Docs

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

xian_tech_py-0.4.8.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

xian_tech_py-0.4.8-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file xian_tech_py-0.4.8.tar.gz.

File metadata

  • Download URL: xian_tech_py-0.4.8.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xian_tech_py-0.4.8.tar.gz
Algorithm Hash digest
SHA256 2090d9e2bb096528d7b97265fbe6f39603f1f60de85a18561b1959796cbad37a
MD5 81d1fbe0889393f4f4e71d43e2bbc1c6
BLAKE2b-256 bb11226b1f3cee7e9c0ab81978d25e46767abe7859e8cc377858bd2ce763f234

See more details on using hashes here.

Provenance

The following attestation bundles were made for xian_tech_py-0.4.8.tar.gz:

Publisher: release.yml on xian-technology/xian-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xian_tech_py-0.4.8-py3-none-any.whl.

File metadata

  • Download URL: xian_tech_py-0.4.8-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xian_tech_py-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0bf21301ed03df5cf8c350e6dc82d7e85fbc475f60ead45d41679f88a3ad02e1
MD5 14e9c749fc2191e93cfe3777d514e329
BLAKE2b-256 b01c18feca2a11f13ec1479c861a45b8d81c89fcc60606650389c012fe4d734e

See more details on using hashes here.

Provenance

The following attestation bundles were made for xian_tech_py-0.4.8-py3-none-any.whl:

Publisher: release.yml on xian-technology/xian-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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