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 #
| Rule | What it means for you |
|---|---|
| Signed | the sender's key signs the envelope; a pass whose bytes changed by one bit is refused |
| Held until accepted | nothing a pass carries runs on the receiving side before the receiver accepts it |
| Priced | every pass names its price in sata; it is metered against the sender's prepaid TNZR |
| Bound to one network | the envelope names its network, so a testnet pass can never be replayed on mainnet |
| Models by badge | a pass that uses a model names that model's badge; filters load only commercially licensed, badged models |
| Recorded | sender and receiver both keep the pass in their tree's journal, exportable as CSV |
The kinds #
| Kind | What goes | Where it runs |
|---|---|---|
tokens | TNZR to a person or network | the chain |
filter | a camera filter: a filter graph naming badged models (face anchors, depth, segmentation, classification) | the receiver's device, at its tier |
game | a game screen plus a signed stream of moves, checked by the game's exact rules | both sides |
inference | an input for a named, badged model; the answer comes back as a pass | your device, a network member, or the pool |
image | an image made or edited, with a receipt per frame | the pool or a member's GPU |
tts | text in, speech back as signed audio segments | the pool or a member's GPU |
train | a fine-tuning job: a base model (by badge), a licensed dataset (by sha256), a recipe, a bid | the pool, on a bonded GPU; the result comes back badged |
app | a small app screen the other side can use and answer through | the receiver's sandbox |
stream | live audio, video or data cut into signed, chained segments | both sides |
render | rendered frames or a pixel stream, each frame with its receipt | the sender's GPU or the pool |
agent | a bound agent with a prompt budget, handed to another member's session | the receiver's session |
package | a set of builds passed as one: a filter set, a model set for a device tier, a game with its assets | wherever 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
- The pass's id is the sha256 of the envelope's bytes.
- The signature is Ed25519 by
<from>over the envelope's bytes, 128 hex characters. - The body travels beside the envelope; the receiver recomputes its sha256 and length before anything else.
A pass is refused with one of these codes, checked in this order:
| Code | Why |
|---|---|
malformed | not exactly ten lines in this format |
unknown_kind | the kind is not in the table above |
wrong_network | the envelope names a network other than the receiver's profile |
bad_signature | the signature does not verify for <from> over these exact bytes |
body_mismatch | the 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:
- Render speed (customer, on or off): on raises the bid toward the customer's cap to reach the front of the queue, and allows the job to be split across cards.
- Sata share (provider, on or off, off by default): on lets this machine's idle GPU take pool jobs and earn sata, within the owner's limits; off stops new jobs at once.
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.
| Op | Input | Output |
|---|---|---|
envelope | the ten fields, one per line (without the first line) | the envelope's bytes |
pubkey | the secret key (64 hex) | the public key (64 hex) |
sign | the secret key (64 hex), then the envelope | the signature (128 hex) |
verify | the profile's network, then the signature, then the body's hex, then the envelope | ok <id> or refused <code> |
package | the set name, the tier, then one <name>\t<sha256>\t<length> line per member, any order | the package's bytes, or refused <code> |
floor | joules sata_per_kWh gpu_ms wear_per_second p_check_ppm | the floor in sata |
payout | escrow bid units fee_ppm | charged fee provider refund |
id | any bytes | their sha256 (a pass's id is the id of its envelope) |
queue | one <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:
- Inbox: passes waiting for you, each with its sender, kind, price and body; accept or refuse.
- Send: pick a kind, a receiver (
#username, a network, or the pool) and a price. - Train: start a fine-tuning job: choose a base model by badge and a licensed dataset, set your bid, and get the trained model back as a badged pass.
- Settings: the two switches (render speed, sata share), your spend limits, and the sites allowed to ask.
See the wallet for creating, unlocking and restoring it.