Skip to main content

Devnet-first Python SDK for TxLINE REST, SSE, validation, and Solana instruction builders.

Project description

TxLINE Python SDK

Devnet-first Python SDK for TxLINE REST APIs, SSE streams, validation helpers, Solana instruction builders, and checked purchase quote transaction bytes.

This package intentionally supports TxLINE Devnet only. Mainnet constants are documented in NOTES.md for source comparison, but mainnet transaction flows are not implemented or presented as safe.

Development

cd python
python -m pip install -e ".[dev]"
python -m pytest
python -m ruff check .
python -m ruff format --check .
python -m mypy src
python -m build

Import name:

import txline

Quick Start

from txline import ApiToken, GuestJwt, TxlineClient, TxlineConfig

with TxlineClient(TxlineConfig.devnet()) as client:
    guest = client.start_guest_session()
    client.set_guest_jwt(guest)
    client.set_api_token(ApiToken("caller-provided-activated-api-token"))

    fixtures = client.fixtures().snapshot()
    print(len(fixtures))

Async clients are available too:

from txline import ApiToken, AsyncTxlineClient, TxlineConfig

async with AsyncTxlineClient(TxlineConfig.devnet()) as client:
    guest = await client.start_guest_session()
    client.set_guest_jwt(guest)
    client.set_api_token(ApiToken("caller-provided-activated-api-token"))
    scores = await client.scores().historical_by_fixture(17952170)

REST Examples

client.set_guest_jwt(GuestJwt("caller-provided-guest-jwt"))
client.set_api_token(ApiToken("caller-provided-api-token"))

odds = client.odds().snapshot(17952170)
scores = client.scores().snapshot(17952170)
legacy = client.scores().stat_validation_legacy(17952170, seq=941, stat_key=1002)
v2 = client.scores().stat_validation_v2(17952170, seq=941, stat_keys=[1001, 1002])

Activation preimage helper:

message = client.activation_preimage("SUBSCRIBE_TX_SIGNATURE", [])

For an empty league bundle, this signs:

SUBSCRIBE_TX_SIGNATURE::guest-jwt

SSE Streams

Streams require both the guest JWT and activated API token to be set on the client.

from txline.sse import StreamOptions

async for event in client.scores_stream().stream(
    StreamOptions(fixture_id=17952170, initial_backoff=1.0, max_backoff=30.0)
):
    print(event.id, event.data.seq)

Streams parse SSE blocks, filter event: heartbeat, preserve Last-Event-ID, respect retry: hints, reconnect after interruptions, and refresh guest JWTs on stream 401/403.

Validation Helpers

from txline.validation import Comparison, NDimensionalStrategy, TraderPredicate

strategy = (
    NDimensionalStrategy.builder(stat_count=2)
    .single(0, TraderPredicate(1, Comparison.GREATER_THAN))
    .build()
)

payload = v2.to_validation_input()

Proof hashes decode from base64, URL-safe base64, hex, or byte arrays and must be exactly 32 bytes.

Solana Instruction Builders

from txline.solana import Pubkey
from txline.solana.instructions import subscribe_instruction

solana = client.solana()
pdas = solana.pdas()
user = Pubkey.from_string("11111111111111111111111111111111")

ix = subscribe_instruction(
    solana.program_id(),
    pdas.subscribe_accounts(user),
    service_level_id=1,
    weeks=4,
)

The SDK builds deterministic instruction data and account metas for subscription, faucet, purchase, validation, and low-level public trading instructions. It does not sign or send transactions.

Purchase Quote Safety

Use checked purchase quote flows before signing backend-provided transaction bytes:

checked = client.purchase_quote_checked(
    buyer="buyer-public-key",
    txline_amount=1_000,
    expected_backend_signer="backend-public-key",
)
tx_bytes = checked.transaction_bytes()

The checker verifies the expected backend signer, decodes the transaction, rejects address table lookups, limits invoked programs, requires exactly one TxLINE purchase_subscription_token_usdt instruction, verifies the requested amount, and checks the expected Devnet account layout.

Live examples require caller-provided credentials, wallet signatures, and wallet/RPC code. Do not commit JWTs, API tokens, private keys, seed phrases, wallet signatures, or full auth headers.

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

txline-0.3.5.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

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

txline-0.3.5-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file txline-0.3.5.tar.gz.

File metadata

  • Download URL: txline-0.3.5.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for txline-0.3.5.tar.gz
Algorithm Hash digest
SHA256 d241a3a6066c45bed7b4fbd34940bf611ea7327fe049623d3175314e07ffb626
MD5 32923208083e69b9025e1f00b6842b2e
BLAKE2b-256 03c16130dd35ccb6cedafae17c7de52ff9a048ad82c8fff8b56d0e0f92d5620d

See more details on using hashes here.

Provenance

The following attestation bundles were made for txline-0.3.5.tar.gz:

Publisher: release.yml on Berektassuly/txline

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

File details

Details for the file txline-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: txline-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for txline-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cbda260eaaf35c6881bff808477f41f9513ea61e9d4ebdff9a13133740bb31dd
MD5 0829ac3bf2d13c71c6e161dc337a1797
BLAKE2b-256 a1918a595f2bb0c796e82468768399ed2b4c5d87c85c2768be725e872523682e

See more details on using hashes here.

Provenance

The following attestation bundles were made for txline-0.3.5-py3-none-any.whl:

Publisher: release.yml on Berektassuly/txline

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