Skip to main content

Python SDK for the Dilithia RPC surface

Project description

Dilithia Python SDK

Python SDK for the Dilithia RPC surface.

Current SDK line: 0.3.0

Install

pip install dilithia-sdk

httpx is installed automatically. For the optional Rust-backed crypto bridge:

pip install dilithia-sdk[native]

Quick start (sync)

from dilithia_sdk import DilithiaClient

with DilithiaClient("https://rpc.example/rpc") as client:
    bal = client.balance("alice")
    print(f"{bal.address}: {bal.balance.formatted()} DILI")

    info = client.network_info()
    print(f"chain={info.chain_id} height={info.block_height}")

Quick start (async)

import asyncio
from dilithia_sdk import AsyncDilithiaClient

async def main():
    async with AsyncDilithiaClient("https://rpc.example/rpc") as client:
        bal = await client.balance("alice")
        print(f"{bal.address}: {bal.balance.formatted()} DILI")

asyncio.run(main())

Typed responses

All read methods return frozen dataclasses:

  • Balance with address: Address and balance: TokenAmount
  • Nonce with address: Address and next_nonce: int
  • Receipt with tx_hash: TxHash, block_height, status, etc.
  • NetworkInfo with chain_id, block_height, base_fee
  • GasEstimate with gas_limit, base_fee, estimated_cost
  • NameRecord with name and address: Address
  • QueryResult wrapping any contract query return value

Token amounts use Decimal to avoid floating-point issues:

from dilithia_sdk import TokenAmount

t = TokenAmount.dili("1.5")
raw = t.to_raw()        # 1500000000000000000
back = TokenAmount.from_raw(raw)
print(back.formatted())  # 1.500000000000000000

Exception hierarchy

All exceptions inherit from DilithiaError:

  • RpcError(code, message) -- JSON-RPC error
  • HttpError(status_code, body) -- non-2xx HTTP response
  • TimeoutError -- request or polling timeout
  • CryptoError -- native crypto failures
  • ValidationError -- invalid input

Gas sponsor

from dilithia_sdk import DilithiaClient, DilithiaGasSponsorConnector

client = DilithiaClient("https://rpc.example/rpc")
sponsor = DilithiaGasSponsorConnector(client, "wasm:gas_sponsor", paymaster="gas_sponsor")
call = client.build_contract_call("wasm:amm", "swap", {"amount": 100})
sponsor.send_sponsored_call(call, signer)

Crypto adapter

from dilithia_sdk import load_native_crypto_adapter

crypto = load_native_crypto_adapter()
if crypto:
    mnemonic = crypto.generate_mnemonic()
    account = crypto.recover_hd_wallet(mnemonic)

Commands

python -m pip install -e .
python -m unittest discover -s tests
python -m build

Requires Python 3.11--3.14.

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

dilithia_sdk-0.3.0.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

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

dilithia_sdk-0.3.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file dilithia_sdk-0.3.0.tar.gz.

File metadata

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

File hashes

Hashes for dilithia_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c96ddc7df819a9f6d06d33fa653dc6c0e4d78798eb95cd3c4d3388e2cbc906b8
MD5 54c4ef809831c5582a1e84dde36cf122
BLAKE2b-256 df991a25eead7666e5cd18a60d38e19aed493542d177009c24d43a09db13f43d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dilithia_sdk-0.3.0.tar.gz:

Publisher: python.yml on dilithia/languages-sdk

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

File details

Details for the file dilithia_sdk-0.3.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dilithia_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fce12947f579862f35aee2f07c7ce5fbb23b62e144d2a20002d9d6bce69fbf07
MD5 0bd4a73ac7ef081a25487058604c2454
BLAKE2b-256 89e447d828097e2c243e0824dad1873f24844219acc79cd0c975a91c005cab89

See more details on using hashes here.

Provenance

The following attestation bundles were made for dilithia_sdk-0.3.0-py3-none-any.whl:

Publisher: python.yml on dilithia/languages-sdk

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