The Pass SDK #

Everything you send from a TensorChain wallet travels as a pass: one signed envelope from a sender's wallet to a person (#username), a network, or the compute pool. A camera filter, a game move, a prompt for a model, an image, a voice clip, an app screen, a fine-tuning job, a set of builds: each is a pass of a different kind, with the same envelope, the same receipt and the same rules.

The SDK is one Rust core (tc-pass). The wallet and web apps use it compiled to WebAssembly; Python uses the same compiled library; servers, GPU nodes and office networks link it directly. No language has a second implementation, so every pass is the same bytes everywhere, and a shared set of test vectors proves it.

Status: the formats on this page are version 1. Prices are in sata (1 TNZR = 1,000,000,000 sata). The chain network comes from your network profile (local, testnet or mainnet); mainnet is not enabled yet, and TNZR is not for sale.

The rules every pass follows #

RuleWhat it means for you
Signedthe sender's key signs the envelope; a pass whose bytes changed by one bit is refused
Held until acceptednothing a pass carries runs on the receiving side before the receiver accepts it
Pricedevery pass names its price in sata; it is metered against the sender's prepaid TNZR
Bound to one networkthe envelope names its network, so a testnet pass can never be replayed on mainnet
Models by badgea pass that uses a model names that model's badge; filters load only commercially licensed, badged models
Recordedsender and receiver both keep the pass in their tree's journal, exportable as CSV

The kinds #

KindWhat goesWhere it runs
tokensTNZR to a person or networkthe chain
filtera camera filter: a filter graph naming badged models (face anchors, depth, segmentation, classification)the receiver's device, at its tier
gamea game screen plus a signed stream of moves, checked by the game's exact rulesboth sides
inferencean input for a named, badged model; the answer comes back as a passyour device, a network member, or the pool
imagean image made or edited, with a receipt per framethe pool or a member's GPU
ttstext in, speech back as signed audio segmentsthe pool or a member's GPU
traina fine-tuning job: a base model (by badge), a licensed dataset (by sha256), a recipe, a bidthe pool, on a bonded GPU; the result comes back badged
appa small app screen the other side can use and answer throughthe receiver's sandbox
streamlive audio, video or data cut into signed, chained segmentsboth sides
renderrendered frames or a pixel stream, each frame with its receiptthe sender's GPU or the pool
agenta bound agent with a prompt budget, handed to another member's sessionthe receiver's session
packagea set of builds passed as one: a filter set, a model set for a device tier, a game with its assetswherever its members run

The envelope, byte for byte (tc-pass.v1) #

The envelope is UTF-8 text, one field per line, every line ending in one \n (0x0a). Integers are base-10 with no sign and no leading zeros (zero is 0); hex is lowercase.

tc-pass.v1
<network>          local | testnet | mainnet
<kind>             one of the kinds above
<from>             the sender's public key, 64 hex characters (Ed25519)
<to>               #username | net:<network id> | pool | key:<64 hex>
<price>            sata
<nonce>            the sender's counter, never reused
<time>             milliseconds since 1970-01-01 UTC
<body sha256>      64 hex characters
<body length>      bytes

A pass is refused with one of these codes, checked in this order:

CodeWhy
malformednot exactly ten lines in this format
unknown_kindthe kind is not in the table above
wrong_networkthe envelope names a network other than the receiver's profile
bad_signaturethe signature does not verify for <from> over these exact bytes
body_mismatchthe body's sha256 or length differs from the envelope

Packages and sets (tc-pass.package.v1) #

A package lists its members by name and sha256, sorted by name, so the same set always has the same bytes and id:

tc-pass.package.v1
<set name>
<tier>             T0 | T1 | T2 | T3 | gpu | -
<member count>
<name>\t<sha256>\t<length>      one line per member, sorted by name (byte order)

Member names are 1 to 128 bytes, with no tab, newline, / or \, and unique. A package is accepted or refused whole: one member whose bytes don't match its line refuses the package (member_mismatch).

Metering compute #

All amounts are whole sata. Divisions round up for what a provider is owed (the floor) and down for the platform's fee, so the customer is never charged a fraction and the provider never receives below the floor.

A provider's floor for one job, from its measured energy and GPU time:

energy  = ceil(joules × sata_per_kWh / 3,600,000)
wear    = ceil(gpu_ms × wear_per_second / 1,000)
floor   = ceil((energy + wear) × (1,000,000 + p_check_ppm) / 1,000,000)

The payout, on a verified job: the customer escrowed escrow, bid bid per unit, and the meter measured units:

charged  = min(bid × units, escrow)
fee      = floor(charged × fee_ppm / 1,000,000)
provider = charged − fee
refund   = escrow − charged          provider + fee + refund = escrow, always

The bid queue #

Jobs are served highest bid per unit first; equal bids go in arrival order, then by pass id. A job whose bid per unit is below every available provider's floor per unit waits; the queue records, for each job served, the jobs it was served ahead of.

Two switches change how a job is placed, and both are written into its receipt:

Calling the SDK #

The core has one call: call(op, input) -> output, where input and output are bytes. Every language's binding is only this call; the operations are the same everywhere. A refusal comes back as refused <code>; the meter refuses overflow rather than wrap, and a ppm above 1,000,000 is bad_ppm. The test vectors every binding must reproduce are crates/tc-pass/vectors.json.

OpInputOutput
envelopethe ten fields, one per line (without the first line)the envelope's bytes
pubkeythe secret key (64 hex)the public key (64 hex)
signthe secret key (64 hex), then the envelopethe signature (128 hex)
verifythe profile's network, then the signature, then the body's hex, then the envelopeok <id> or refused <code>
packagethe set name, the tier, then one <name>\t<sha256>\t<length> line per member, any orderthe package's bytes, or refused <code>
floorjoules sata_per_kWh gpu_ms wear_per_second p_check_ppmthe floor in sata
payoutescrow bid units fee_ppmcharged fee provider refund
idany bytestheir sha256 (a pass's id is the id of its envelope)
queueone <id> <bid> <arrival> line per job, then floor <sata per unit>serve <ids in serving order>, then waiting <ids below the floor>
from tensorchain import passsdk                   # the compiled core, through its C interface

env = passsdk.call("envelope", "testnet\ntrain\n" + me + "\npool\n5000000\n7\n1764100000000\n" + body_sha + "\n" + str(len(body)) + "\n")
sig = passsdk.call("sign", secret_hex + "\n" + env)
print(passsdk.call("verify", "testnet\n" + sig + "\n" + body.hex() + "\n" + env))   # ok <id>

The same calls from the wallet, in the browser:

const core = await TCPass.load("/tc-pass.wasm");   // the same Rust, compiled to WebAssembly
const env = core.call("envelope", fields);

The wallet #

The wallet holds your key and your TNZR, and shows every pass you sent and received:

See the wallet for creating, unlocking and restoring it.