Tx3 SDK for Python
Project description
tx3-sdk (Python)
The official Python SDK for Tx3: a DSL and protocol suite for
defining and executing UTxO-based blockchain transactions declaratively. Load a
compiled .tii protocol, bind parties and signers, and drive the full
transaction lifecycle (resolve -> sign -> submit -> wait) through TRP.
This repository is organized as a monorepo. The publishable Python package lives in sdk/.
Installation
pip install tx3-sdk
Quick start
import asyncio
from tx3_sdk import CardanoSigner, Party, PollConfig, Protocol, TrpClient, Tx3Client
async def main() -> None:
# 1) Load a compiled .tii protocol
protocol = Protocol.from_file("examples/transfer.tii")
# 2) Create a low-level TRP client
trp = TrpClient(endpoint="https://preprod.trp.tx3.dev")
# 3) Configure signer and parties
sender_signer = CardanoSigner.from_mnemonic(
address="addr_test1qz...",
phrase="word1 word2 ... word24",
)
client = (
Tx3Client(protocol, trp)
.with_profile("preprod")
.with_party("sender", Party.signer(sender_signer))
.with_party("receiver", Party.address("addr_test1qz..."))
)
# 4) Build, resolve, sign, submit
submitted = await (
await (
await client.tx("transfer").arg("quantity", 10_000_000).resolve()
).sign()
).submit()
# 5) Wait for confirmation
status = await submitted.wait_for_confirmed(PollConfig.default())
print(f"Confirmed at stage: {status.stage}")
asyncio.run(main())
Concepts
| SDK Type | Glossary Term | Description |
|---|---|---|
Protocol |
TII / Protocol | Loaded .tii with transactions, parties, and profiles |
Tx3Client |
Facade | High-level client holding protocol + TRP + party bindings |
TxBuilder |
Invocation builder | Collects args and resolves transactions |
Party |
Party | Party.address(...) or Party.signer(...) |
Signer |
Signer | Interface for witness-producing signing implementations |
ResolvedTx |
Resolved transaction | Output of resolve(), ready for signing |
SignedTx |
Signed transaction | Output of sign(), ready for submission |
SubmittedTx |
Submitted transaction | Output of submit(), pollable for status |
PollConfig |
Poll configuration | Poll attempts and delay for wait modes |
Advanced usage
Low-level TRP client
from tx3_sdk import TrpClient
from tx3_sdk.trp import ResolveParams
trp = TrpClient(endpoint="http://localhost:8000", headers={"Authorization": "Bearer token"})
envelope = await trp.resolve(ResolveParams(tir=..., args={"quantity": 100}))
Custom Signer
from tx3_sdk import Signer
from tx3_sdk.signer import TxWitness
class MySigner(Signer):
def address(self) -> str:
return "addr_test1..."
def sign(self, tx_hash_hex: str) -> TxWitness:
return TxWitness.vkey(public_key_hex="aabb", signature_hex="ccdd")
Tx3 protocol compatibility
- TRP protocol version:
v1beta0 - TII schema version:
v1beta0
Testing
- Tests follow Python's idiomatic centralized layout under
sdk/tests/. - End-to-end (e2e) tests are marked with
@pytest.mark.e2eand selected by marker.
# from python-sdk/sdk
pytest -m "not e2e"
pytest tests/e2e -m e2e
License
Apache-2.0
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 tx3_sdk-0.10.0.tar.gz.
File metadata
- Download URL: tx3_sdk-0.10.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a176fa7bc4da32e8b8bc3cfc1401622c8bc81032adc8276fb31bb67ba06c078
|
|
| MD5 |
dd9818e6a154727f95f97e127e356a53
|
|
| BLAKE2b-256 |
84a84ead7a13241015bf0eb3bf60303dba354f59c750f9c1524b3702d79d1f16
|
File details
Details for the file tx3_sdk-0.10.0-py3-none-any.whl.
File metadata
- Download URL: tx3_sdk-0.10.0-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b526f5c5f146bf925e85bae161a0ef4de96d8748b0f01b965e394742fba8413c
|
|
| MD5 |
7d4751eb3afda58b3f49cb066c66d7d5
|
|
| BLAKE2b-256 |
353b0a5664b37c41460d04a272b12bdf19a191073bbf2a016d3203e0e3e331fc
|