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:
Balancewithaddress: Addressandbalance: TokenAmountNoncewithaddress: Addressandnext_nonce: intReceiptwithtx_hash: TxHash,block_height,status, etc.NetworkInfowithchain_id,block_height,base_feeGasEstimatewithgas_limit,base_fee,estimated_costNameRecordwithnameandaddress: AddressQueryResultwrapping 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 errorHttpError(status_code, body)-- non-2xx HTTP responseTimeoutError-- request or polling timeoutCryptoError-- native crypto failuresValidationError-- 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
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c96ddc7df819a9f6d06d33fa653dc6c0e4d78798eb95cd3c4d3388e2cbc906b8
|
|
| MD5 |
54c4ef809831c5582a1e84dde36cf122
|
|
| BLAKE2b-256 |
df991a25eead7666e5cd18a60d38e19aed493542d177009c24d43a09db13f43d
|
Provenance
The following attestation bundles were made for dilithia_sdk-0.3.0.tar.gz:
Publisher:
python.yml on dilithia/languages-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dilithia_sdk-0.3.0.tar.gz -
Subject digest:
c96ddc7df819a9f6d06d33fa653dc6c0e4d78798eb95cd3c4d3388e2cbc906b8 - Sigstore transparency entry: 1154426289
- Sigstore integration time:
-
Permalink:
dilithia/languages-sdk@b23e9c551adbd358407b6c9dfa8888d5808e13d9 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/dilithia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@b23e9c551adbd358407b6c9dfa8888d5808e13d9 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fce12947f579862f35aee2f07c7ce5fbb23b62e144d2a20002d9d6bce69fbf07
|
|
| MD5 |
0bd4a73ac7ef081a25487058604c2454
|
|
| BLAKE2b-256 |
89e447d828097e2c243e0824dad1873f24844219acc79cd0c975a91c005cab89
|
Provenance
The following attestation bundles were made for dilithia_sdk-0.3.0-py3-none-any.whl:
Publisher:
python.yml on dilithia/languages-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dilithia_sdk-0.3.0-py3-none-any.whl -
Subject digest:
fce12947f579862f35aee2f07c7ce5fbb23b62e144d2a20002d9d6bce69fbf07 - Sigstore transparency entry: 1154426292
- Sigstore integration time:
-
Permalink:
dilithia/languages-sdk@b23e9c551adbd358407b6c9dfa8888d5808e13d9 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/dilithia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@b23e9c551adbd358407b6c9dfa8888d5808e13d9 -
Trigger Event:
release
-
Statement type: