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 over the CometBFT websocket:
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())
Watch raw live events directly from the CometBFT websocket:
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_live():
print(event.tx_hash, event.data)
asyncio.run(main())
By default the SDK derives the websocket endpoint from the RPC URL, for example
http://127.0.0.1:26657 -> ws://127.0.0.1:26657/websocket. If you need an
override, set WatcherConfig(websocket_url="ws://rpc-host:26657/websocket").
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 websocket event delivery, catch-up cursors, raw CometBFT decoding, and typed event conversion.
- 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 primitivesexamples/: service, worker, and automation examples built on the SDKtests/: SDK transport, decoding, and integration-shape coveragedocs/: 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, andcommitmodes - 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 indexed events with websocket live delivery plus resumable BDS cursors
- watch raw live websocket events without BDS when low-latency delivery matters more than replayable 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, using CometBFT websocket wakeups while keeping BDS cursor reconciliation
Event watching uses the CometBFT websocket directly and still expects a
BDS-enabled node for cursorable indexed catch-up and canonical event IDs.
Use watch_live_events() or .watch_live() when you explicitly want
websocket-only, non-resumable delivery.
Core API Layers
XianandXianAsync: the primary sync and async clientsclient.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 projectionsWallet: 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
- general SDK examples: examples/README.md
- credits-ledger reference app: examples/credits_ledger/README.md
- registry-approval reference app: examples/registry_approval/README.md
- workflow-backend reference app: examples/workflow_backend/README.md
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xian_tech_py-0.4.13.tar.gz.
File metadata
- Download URL: xian_tech_py-0.4.13.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dff503a9b815cc201c19ee60ee57f364c637e8553575bfd8af152b4aa78214c
|
|
| MD5 |
02842e91e78b13250ec2bcc690ff6eb4
|
|
| BLAKE2b-256 |
d20536bea6072012630fbfc5200b1390d1e1ade72603806ef8b4a48d7c41b901
|
Provenance
The following attestation bundles were made for xian_tech_py-0.4.13.tar.gz:
Publisher:
release.yml on xian-technology/xian-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_py-0.4.13.tar.gz -
Subject digest:
1dff503a9b815cc201c19ee60ee57f364c637e8553575bfd8af152b4aa78214c - Sigstore transparency entry: 1321761984
- Sigstore integration time:
-
Permalink:
xian-technology/xian-py@19334e2ebef2a9925a83989a3c1cd6245e854b3d -
Branch / Tag:
refs/tags/v0.4.13 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@19334e2ebef2a9925a83989a3c1cd6245e854b3d -
Trigger Event:
push
-
Statement type:
File details
Details for the file xian_tech_py-0.4.13-py3-none-any.whl.
File metadata
- Download URL: xian_tech_py-0.4.13-py3-none-any.whl
- Upload date:
- Size: 44.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
443affe16513d2e68095cd80cbcd3e62b2d7431ee478994aa036063d0d26a46e
|
|
| MD5 |
e13ff0cea3a46b986bc37b141e7570a9
|
|
| BLAKE2b-256 |
39de7a91030faaf71fef867b7c0350cf63dc29469e7ed3c956f461d238934ea9
|
Provenance
The following attestation bundles were made for xian_tech_py-0.4.13-py3-none-any.whl:
Publisher:
release.yml on xian-technology/xian-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_py-0.4.13-py3-none-any.whl -
Subject digest:
443affe16513d2e68095cd80cbcd3e62b2d7431ee478994aa036063d0d26a46e - Sigstore transparency entry: 1321762058
- Sigstore integration time:
-
Permalink:
xian-technology/xian-py@19334e2ebef2a9925a83989a3c1cd6245e854b3d -
Branch / Tag:
refs/tags/v0.4.13 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@19334e2ebef2a9925a83989a3c1cd6245e854b3d -
Trigger Event:
push
-
Statement type: