Docs
Reserve before you spend.
Sennet sits between your workers and the chain. Every worker asks before it spends, gets a hold on the amount, signs with your own signer, and reports the signature. Sennet keeps the shared count so fifty workers never commit the same lamport twice.
Why Sennet
One process with one wallet is fine. Fifty processes on the same wallet read the same balance at the same moment, and each one thinks the money is its own. What goes wrong at fifty workers:
- Two workers spend the same USDC.
- Both create the same token account.
- One pays rent the other expected to have.
- A retry lands twice.
- The balance the code reads is already stale.
Where it fits: between your runtime and your signer
Today the usual answer is one wallet per worker, and moving funds between them by hand. Sennet lets them share one.
- Agent runtimes
- make one worker durable.
- Wallet providers
- sign.
- Sennet
- tracks what all your workers together have already committed from the same balance.
Quick start
- Create a project in the console with a name and the wallet's public address. You get an owner key (
sn_own_…) and a worker key (sn_wrk_…), shown once. - Give Sennet a balance. Press Read from chain (when the server has an RPC), or set balances by hand.
- Give every worker the worker key, this server's address and its own name.
// TypeScript: copy /sdk/sennet.ts into your project
import { Sennet } from "./sennet";
const sn = new Sennet({ url: process.env.SENNET_URL, key: process.env.SENNET_WORKER_KEY, worker: "worker-17" });
const r = await sn.reserve({ asset: "USDC", amount: "2500000", blockhash: true }); // throws "insufficient" if not enough is free
const sig = await signAndSend(tx, r.blockhash); // your own signer, your own keys
await sn.submit(r.id, sig); // settled when it lands, released if it fails
All calls send Authorization: Bearer <key> and JSON bodies. Amounts are whole base units (lamports, token base units) as strings, so large values stay exact.
How the ledger counts
For every asset (SOL, USDC, any mint) Sennet keeps four figures:
- On chain
- The last reading of the wallet: from chain, set by hand, or estimated (last reading minus what settled since).
- Reserved
- Held for workers that have not sent yet.
- Submitted
- Sent, waiting to land. Still counted against the balance.
- Free
- On chain − reserved − submitted. A reservation is only granted from free balance.
A spend, step by step
Every spend passes through one junction. A worker reserves before it builds a transaction, so no two workers can count on the same funds.
- Reserve. The worker asks for an amount. Sennet holds it against the free balance, or says no.
- Sign with your key. Your own signer builds and signs the transaction with the blockhash or nonce Sennet handed back.
- Submit. The worker reports the signature. The reservation is now pending on chain.
- Settle or release. When it lands, the hold settles (by itself when the server has an RPC, or by one call). A held amount that is never sent goes back to free; a submitted one counts as spent until the next balance reading.
Reserve
POST /api/v1/reserve
worker | Your name for this worker, 1-64 of A-Z a-z 0-9 _ . : -. Required. |
|---|---|
asset | "SOL", "USDC" or a token mint address. Required. |
amount | Base units as a string, more than zero. Include the fee and any rent you might pay in a separate SOL reservation. Required. |
ttl_s | Seconds the hold lasts if nothing is submitted: 5-900, default 60. It then expires and frees the amount. |
idempotency_key | Retries with the same key return the same reservation (replay: true) instead of a second hold. |
blockhash | true to get a fresh blockhash in the answer (needs an RPC on the server; otherwise blockhash: null with blockhash_error). |
nonce | true to lease a durable nonce account from your pool for the life of this reservation. |
memo | Up to 140 characters, shown in the console. |
Answers 201 with the reservation (id, state: "held", expires_at, …), or 409 insufficient with requested and free. Each grant runs in one database transaction, so two workers can never both take the last of a balance.
Submit, settle, release
POST /api/v1/reservations/:id/submit | { "signature" } once the transaction is sent. The hold moves to submitted and lasts at least 120 s more. With an RPC, Sennet checks the signature every few seconds: landed → settled, failed → released. |
|---|---|
POST /api/v1/reservations/:id/settle | Mark it spent yourself. Optional spent (≤ the reserved amount) when less was used; the rest is freed. |
POST /api/v1/reservations/:id/release | You did not send. Frees the hold and any nonce it carried. |
GET /api/v1/reservations/:id | Current state. GET /api/v1/reservations?live=1 lists holds. |
A submitted hold that reaches its time without any confirmation is counted as spent, never freed: it may have landed. The next balance reading corrects the figure either way. Sennet always errs toward holding back, not overspending.
Once-only keys
For things that must never run twice across the fleet: creating or closing an account, paying a given invoice. You choose the key, for example create-ata:<owner>:<mint> or pay:invoice-81. The first worker to claim it runs it; every other worker gets the stored result.
await sn.once("create-ata:" + owner + ":" + mint, async () => createAta());
POST /api/v1/once/claim | { key, worker, ttl_s? } (lease 5-3600 s, default 300). 201 claimed with a token; 409 running while another worker holds it; 200 done with the stored result once it finished. |
|---|---|
POST /api/v1/once/complete | { key, token, result? }: any JSON up to 4000 characters, returned to every later claim. |
POST /api/v1/once/abandon | { key, token }: you did not do it; the key is free again. |
If a claim's lease runs out without complete or abandon (the worker crashed), the next claim gets it with recovered: true and previous_worker. The earlier attempt may or may not have taken effect, so check the chain first; the SDKs' once() takes a recover callback for exactly this. The owner can forget a key in the console to let it run again.
Nonces and blockhashes
GET /api/v1/blockhash returns { blockhash, last_valid_block_height }, cached for two seconds so a busy fleet does not hammer the RPC.
A reservation can come back with a fresh blockhash (blockhash: true). Durable nonces go to a single worker at a time, so two transactions never race for one.
For transactions that may wait longer than a blockhash lives, register durable nonce accounts you created (owner key, POST /api/v1/nonces with { addresses: [...] }, up to 500). Sennet leases each one to a single worker at a time:
POST /api/v1/nonces/lease | { worker, ttl_s? } (5-900 s, default 120) → { address, token, lease_until, nonce_value }. nonce_value is read from chain when the server has an RPC. |
|---|---|
POST /api/v1/nonces/return | { address, token } after your transaction advanced it (or you did not use it). |
Or pass nonce: true to reserve: the nonce is tied to the reservation and returns when it settles, is released or expires.
Balances
POST /api/v1/sync | Reads SOL and every SPL and Token-2022 balance of the wallet from chain (at most every 10 s per project). Needs an RPC on the server, otherwise 503 rpc_unavailable. |
|---|---|
PUT /api/v1/balances | Owner key. { asset, amount, decimals? } sets one balance by hand (decimals needed for mints Sennet does not know). |
GET /api/v1/state | Balances with all four figures, live reservations, workers, nonce pool and recent once-only keys. |
GET /api/v1/events | Owner key. The activity log, newest first; ?after=<id> for new ones. |
Settling takes the spent amount off the last reading at once, so the figure stays honest between readings.
Errors and limits
Errors answer with { "error": "<code>", "message": "…" } and an HTTP status:
400 | bad_amount, bad_asset, bad_worker, bad_ttl, bad_signature, spent_over, bad_json |
|---|---|
401 / 403 | unauthorized (missing or unknown key), owner_only |
404 | not_found |
409 | insufficient, unknown_asset (no balance yet), idempotency_mismatch, not_held, not_live, running, lost_claim, no_free_nonce, lost_lease |
429 | rate_limited (12,000 calls a minute per project), sync_too_soon, too_many_live (10,000 live holds) |
503 | rpc_unavailable: no RPC on this server, or its daily RPC budget is used up |
SDKs
Each is one small client over the same HTTP API, with reserve, submit, settle, release, spend (reserve → your send → submit, released if the send throws), once, leaseNonce and returnNonce.
- TypeScriptsennet.ts · one file, no dependencies, Node 18+, Bun, Deno
- Pythonsennet.py · one file, standard library only, 3.9+
- Rustblocking client on ureq · README, then Cargo.toml and src/lib.rs in /sdk/rust/
# Python
from sennet import Sennet
sn = Sennet(SENNET_URL, SENNET_WORKER_KEY, worker="worker-17")
r = sn.reserve(asset="USDC", amount="2500000", blockhash=True)
sn.submit(r["id"], signature)
# once-only: returns the stored result if any worker already did it
ata = sn.once(f"create-ata:{owner}:{mint}", lambda: create_ata(owner, mint))
The crate is not on crates.io: add it as a path or git dependency. gRPC is not available yet; the HTTP API covers everything.
A worker, end to end
What a worker does before it spends. Plain HTTP underneath; workers authenticate with the worker key, you keep the owner key.
TypeScript
import { Sennet } from "./sennet";
const sn = new Sennet({
url: SENNET_URL,
key: process.env.SENNET_WORKER_KEY,
worker: "worker-17",
});
// throws if not enough is free
const r = await sn.reserve({
asset: "USDC",
amount: "2500000",
blockhash: true,
});
// your own signer
const sig = await signAndSend(tx, r.blockhash.blockhash);
// settled when it lands (with an RPC), released if it fails on chain
await sn.submit(r.id, sig);
Python
from sennet import Sennet
sn = Sennet(url, key, worker="worker-17")
# raises if not enough is free
r = sn.reserve(asset="USDC", amount="2500000", blockhash=True)
# your own signer
sig = sign_and_send(tx, r["blockhash"]["blockhash"])
sn.submit(r["id"], sig)
HTTP
POST /api/v1/reserve
Authorization: Bearer sn_wrk_…
{ "worker": "worker-17", "asset": "USDC", "amount": "2500000", "blockhash": true }
# sign and send with your own signer, then:
POST /api/v1/reservations/:id/submit
{ "signature": "…" }
# also: …/:id/settle …/:id/release /api/v1/once/claim
What Sennet never does
- Holds private keys, seed phrases or funds.
- Signs or sends a transaction.
- Trades, swaps or decides what your workers buy.
It keeps the books; your workers and your signer do the rest. It keeps a count, hands out holds, nonces and once-only claims, and writes down what happened. Keys are stored only as hashes.
Questions
What do I need to start?
A project name and the wallet’s public address. Nothing to connect and nothing to sign. You get an owner key for yourself and a worker key for your workers.
What happens if a worker crashes after reserving?
The reservation expires and its amount goes back to free. Nothing stays locked for good.
Which assets does the ledger track?
SOL and the wallet’s tokens, plus every pending transaction your workers have submitted.
Is there a gRPC API?
Not available yet. Today it is plain HTTP, with SDKs for TypeScript, Python and Rust.
Why the name?
A sennit is cord braided from many strands. Many workers, one wallet line.