Trade with the API, or integrate Sirius.
One signed HTTP API, two ways in. Run a bot on your own Sirius account, or build private balances, transfers and trades into your app for your users.
Trade with the API
This path is for your own Sirius account: a bot or a script that trades and reads it. You sign each request with an API key you create in the app. A key can trade and read. It can never withdraw, transfer or claim, because those permissions do not exist.
| Mainnet | |
|---|---|
| Base URL | https://app.siriusprotocol.xyz/api/trade-api/v1 |
| Chain id | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d |
| Public, no key | GET config, GET account/{index}/state/challenge, GET perp/order/{cloid}, GET perp/twap/preview, GET perp/funding |
No SDK package is published yet. The examples below need nothing beyond Node or Python, and any package that claims to be a Sirius SDK is not ours.
1. Create an API key
- Fund your account API keys appear in the app's Settings once your first deposit is credited.
- Create the key Settings, API keys, Create API key. Choose what it may do (Trade, Read or both), when it expires (7, 30, 90 or 365 days) and, if you like, the IP addresses it may be used from (up to 16; empty means any).
- Save the secret The key pair is made in your browser. The app shows the secret once, with the five lines your code reads. Sirius does not keep it. Store it on your server, never in a browser bundle.
- Revoke when done Settings, API keys, Revoke. A key can also revoke
itself (
POST apikeys/revoke). An account can hold up to 10 active keys.
SIRIUS_API_URL=https://app.siriusprotocol.xyz
SIRIUS_CHAIN_ID=solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d
SIRIUS_ACCOUNT_INDEX=<your account index>
SIRIUS_ACCOUNT_ID=<your account id, 64 hex>
SIRIUS_API_SECRET=<the key's secret, 64 hex: shown once>
Anyone holding the secret can trade your account until the key expires or you revoke it. They cannot move money out.
2. Sign a request
Every message starts with a domain tag: the scheme name, the byte 0x1F, then
the chain id, in ASCII. All integers are little-endian. An API key signs the exact bytes the account owner
would sign for the same action, wrapped with the key's own public key. The full list of schemes is in
Signing a request.
key_message = "SIRIUS_API_KEY_SIG_V1" || 0x1F || chain_id || 0x01 || api_pubkey[32] || route_bytes
signature = Ed25519(api_secret, key_message) // 64 bytes, sent as 128 hex
route_bytes = the bytes the account owner would sign for the same action (table in Signing a request)
Send the key's public key as api_key and the signature as hex. Reads use a
single-use challenge: fetch one, sign it, use it within 120 seconds. This reads your open orders.
// Node 22.18+, no packages. Reads your open orders: fetch a challenge, sign it with the API key, POST.
import { createPrivateKey, createPublicKey, sign } from "node:crypto";
const door = process.env.SIRIUS_API_URL!.replace(/\/+$/, "") + "/api/trade-api/v1";
const chain = process.env.SIRIUS_CHAIN_ID!, index = BigInt(process.env.SIRIUS_ACCOUNT_INDEX!);
const pkcs8 = Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), Buffer.from(process.env.SIRIUS_API_SECRET!, "hex")]);
const key = createPrivateKey({ key: pkcs8, format: "der", type: "pkcs8" });
const apiPub = createPublicKey(key).export({ format: "der", type: "spki" }).subarray(-32);
const tag = (name: string) => Buffer.from(`${name}\x1f${chain}`); // domain tag: name || 0x1F || chain_id
const u64 = (v: bigint) => { const b = Buffer.alloc(8); b.writeBigUInt64LE(v); return b; };
const ch = await (await fetch(`${door}/account/${index}/state/challenge`)).json();
const routeBytes = Buffer.concat([tag("SIRIUS_OWNER_READ_V1"), u64(index), u64(BigInt(ch.state_version)), Buffer.from(ch.nonce, "hex")]);
const signature = sign(null, Buffer.concat([tag("SIRIUS_API_KEY_SIG_V1"), Buffer.from([1]), apiPub, routeBytes]), key).toString("hex");
const r = await fetch(`${door}/perp/orders/${index}`, { method: "POST", headers: { "content-type": "application/json" },
body: JSON.stringify({ nonce: ch.nonce, signature, api_key: apiPub.toString("hex") }) });
console.log(r.status, await r.text());
# pip install cryptography. Reads your open orders: fetch a challenge, sign it with the API key, POST.
import json, os, urllib.request
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
door = os.environ["SIRIUS_API_URL"].rstrip("/") + "/api/trade-api/v1"
chain, index = os.environ["SIRIUS_CHAIN_ID"].encode(), int(os.environ["SIRIUS_ACCOUNT_INDEX"])
key = Ed25519PrivateKey.from_private_bytes(bytes.fromhex(os.environ["SIRIUS_API_SECRET"]))
api_pub = key.public_key().public_bytes(Encoding.Raw, PublicFormat.Raw)
tag = lambda name: name.encode() + b"\x1f" + chain # domain tag: name || 0x1F || chain_id
ch = json.loads(urllib.request.urlopen(f"{door}/account/{index}/state/challenge").read())
route_bytes = tag("SIRIUS_OWNER_READ_V1") + index.to_bytes(8, "little") + int(ch["state_version"]).to_bytes(8, "little") + bytes.fromhex(ch["nonce"])
signature = key.sign(tag("SIRIUS_API_KEY_SIG_V1") + b"\x01" + api_pub + route_bytes).hex()
body = json.dumps({"nonce": ch["nonce"], "signature": signature, "api_key": api_pub.hex()}).encode()
req = urllib.request.Request(f"{door}/perp/orders/{index}", data=body, headers={"content-type": "application/json"})
print(json.loads(urllib.request.urlopen(req).read()))
3. Place, change and cancel orders
What a key can do on mainnet today:
| Order | How |
|---|---|
| Limit | POST perp/order with rest_style "gtc". Rests until filled, cancelled or its not_after (up to 30 days). |
| Post only | The same with rest_style "alo": it only adds to the book. If it would fill on arrival, the venue cancels it. |
| Reduce only | reduce_only: true and no leverage. It must cover the whole position, or it is refused with SIZE_MUST_COVER_POSITION. |
| Market open | POST perp/open: margin and leverage, with a signed maximum slippage. A key must send the bound (SLIPPAGE_REQUIRED). |
| Market close | POST perp/close: closes the whole position. With no position it answers 409 CONFLICT. |
| Amend | No in-place amend by key yet. Cancel, wait for the answer, then place a new order with a new nonce. |
| Stop loss, take profit | Not by API key on mainnet yet: perp/protection answers 400 ENGINE_PROTECTIONS_KEY_UNSUPPORTED. Set them in the app. While one rests on a position, adding to that position is refused until you cancel it. |
| TWAP | GET perp/twap/preview, then POST perp/twap signing the preview's disclosure_id; perp/twap/cancel to stop. Below the venue's $100 TWAP minimum it is sent as one order. |
| Immediate or cancel | Not available yet. |
| Spot | POST spot/order and spot/order/cancel (limit, gtc or post only). Spot stops and take-profits are not available yet. |
A resting limit and its cancel look like this. The signed bytes are
SIRIUS_PERP_OPEN_ORDER_V1 (opening) or SIRIUS_PERP_ORDER_V1
(reduce only) and SIRIUS_PERP_ORDER_CANCEL_V1; the example bot below builds them.
POST perp/order Idempotency-Key: <a new uuid per order, reused on a retry>
{
"order": {
"account_index": 1234, "account_id": "<64 hex>", "asset": 1, "side": "buy",
"reduce_only": false, "rest_style": "alo", "leverage": 2,
"size_base": "210000", // 0.00021 BTC, 9 decimals
"limit_price_fp": "57988000000000", // $57,988, 9 decimals
"take_profit_fp": "0", "stop_loss_fp": "0",
"not_before": 1794690000, "not_after": 1794776430, "order_nonce": 1794690030123001
},
"signature": "<128 hex>",
"api_key": "<your key's public key, 64 hex>"
}
POST perp/order/cancel
{ "account_id": "<64 hex>", "order_nonce": 1794690030123001, "not_after": 1794690330,
"signature": "<128 hex>", "api_key": "<64 hex>" }
- Your nonce is your order id.
order_nonceis yours to choose and must be new. The order'scloidis the first 16 bytes ofsha256(tag("SIRIUS_PERP_ORDER_CLOID_V1") || account_id || order_nonce u64), so you know it before you send. - Retry safely. Send an
Idempotency-Keyheader on every trading POST. On a retry, send the same body and the same key; a repeat within 24 hours gets the first answer withIdempotent-Replayed: true. Never make a new nonce for a retry. - Times. Set
not_beforeto now minus 30 seconds. A cancel'snot_aftermay be at most 600 seconds ahead. - Sizes and prices. Both carry 9 decimals and are sent as strings. The minimum trade is $10. Use sizes and prices the venue accepts (for BTC: 5 size decimals, whole-dollar prices).
- Leverage. Up to the market's
max_leverageinGET config. If you already hold that market at another leverage, the order is refused withMIXED_LEVERAGE. - Assets. BTC, ETH, SOL and HYPE are assets 1 to 4. Any other perp is
1024 + fnv1a64(upper-case name) mod 2^20; the bot'sperpAssetIdcomputes it. - One order.
GET perp/order/{cloid}answers from the engine's latest read of the venue book. Right after a place it may answer429for a few seconds; the signedperp/orders/{index}read is the reliable list.
4. Read your account
Every read is signed with a fresh challenge (see Sign a request) and needs the Read permission.
| Read | Route and body |
|---|---|
| Positions | POST perp/positions with account_index, nonce_hex, signature_hex, api_key (its own field names) |
| Open orders | POST perp/orders/{index}, spot: spot/orders/{index}, with nonce, signature, api_key |
| Balance | POST account/{index}/state: answers plaintext, hex. Entries of 48 bytes start at byte 26 (asset id 32, units u128); the all-zero id is USDC in micro-dollars |
| Fills and funding | POST account/{index}/trades, optional cursor, limit, since, until, market, instrument, include_funding; page with next_cursor |
| Stops and take-profits | POST perp/protections/{index} |
| Your keys and budget | POST apikeys/list/{index}: keys, caps, use, and rate_limit_per_min |
| Live updates | GET apikeys/stream/{index}: Server-Sent Events (snapshot, then positions, orders, balances, fills), signed in the X-Sirius-Api-Key, X-Sirius-Nonce, X-Sirius-Signature headers |
5. Rate budget and errors
- An account has 120 signed requests a minute, shared by all of its API keys. Reads count. Read the live number from
apikeys/list. Over it, the answer is429 RATE_LIMITEDwithRetry-Afterin seconds. - Public routes need no key. Read challenges are limited to 64 per client IP, so fetch one per read and use it at once.
- Network caps per order and per rolling 24 hours may apply:
ORDER_CAP_EXCEEDED,DAY_CAP_EXCEEDED.
An error to a key-signed request has the body {"error", "message", "code", "retryable"}
and the header X-Sirius-Error-Code. Branch on code, retry only when
retryable is true, and show message to people. The ones a bot meets most:
| Code | Status | What to do |
|---|---|---|
KEY_NOT_REGISTERED, KEY_REVOKED, KEY_EXPIRED | 401 | Check the five lines, or make a new key. |
IP_NOT_ALLOWED | 401 | Add this server's address to the key, or make a key without a list. |
BAD_SIGNATURE | 400/401 | Your bytes differ from the engine's. Check the domain tag, byte order and field order. |
CHALLENGE_INVALID | 401 | Fetch a fresh challenge for each read. |
RATE_LIMITED | 429 | Wait Retry-After seconds. |
DUPLICATE_ORDER | 400 | That nonce was used. A new order needs a new nonce. |
INSUFFICIENT_BALANCE | 400/422 | Not enough free balance for the margin. |
LEVERAGE_TOO_HIGH, MIXED_LEVERAGE | 400 | Use the market's limit, or your open position's leverage. |
SLIPPAGE_REQUIRED, SLIPPAGE_EXCEEDED | 400/422 | Send a slippage bound with a market open, or widen it. |
ENGINE_PROTECTIONS_KEY_UNSUPPORTED | 400 | Set stops and take-profits in the app. |
VENUE_UNAVAILABLE, SERVICE_UNAVAILABLE | 400/503 | Retryable: same body, same Idempotency-Key. |
The full list is in Errors and limits.
6. Example bot
A complete bot in one file. It reads the BTC mark from the venue's public market data, rests a post-only buy 10% under it for about $12 at 2x, lists your open orders, cancels the order, then reads your positions and USDC balance. It needs a funded account and a key with Trade and Read.
Run against mainnet, the order is real. Ten percent under the mark it should rest, and the bot cancels it a moment later. If the script stops in between, cancel the order in the app.
// Sirius example bot: read the BTC mark, rest a small post-only buy below it, read it back, cancel it.
// Node 22.18 or later runs this file as is (`node sirius-bot.mts`), with no packages.
// Reads the five lines Settings > API keys shows when you create a key:
// SIRIUS_API_URL, SIRIUS_CHAIN_ID, SIRIUS_ACCOUNT_INDEX, SIRIUS_ACCOUNT_ID, SIRIUS_API_SECRET
import { createHash, createPrivateKey, createPublicKey, randomUUID, sign } from "node:crypto";
const env = (k: string): string => process.env[k] ?? (() => { throw new Error(`${k} is not set`); })();
const DOOR = env("SIRIUS_API_URL").replace(/\/+$/, "") + "/api/trade-api/v1";
const CHAIN = env("SIRIUS_CHAIN_ID");
const INDEX = BigInt(env("SIRIUS_ACCOUNT_INDEX"));
const ACCOUNT_ID = Buffer.from(env("SIRIUS_ACCOUNT_ID"), "hex");
const KEY = createPrivateKey({ key: Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), Buffer.from(env("SIRIUS_API_SECRET"), "hex")]), format: "der", type: "pkcs8" });
const API_PUB = createPublicKey(KEY).export({ format: "der", type: "spki" }).subarray(-32);
const MARKET_DATA = process.env.SIRIUS_MARKET_DATA_URL ?? "https://api.hyperliquid.xyz/info";
// ---- bytes: every integer little-endian, every message starts with tag || 0x1F || chain_id ----
const tag = (name: string) => Buffer.from(`${name}\x1f${CHAIN}`);
function u(v: bigint, n: number): Buffer {
const b = Buffer.alloc(n);
for (let i = 0; i < n; i++) b[i] = Number((v >> BigInt(8 * i)) & 0xffn);
return b;
}
function fixed(dec: string, places: number): bigint { // "0.00021" -> 210000n at 9 places
const [whole, frac = ""] = dec.split(".");
return BigInt(whole) * 10n ** BigInt(places) + BigInt((frac + "0".repeat(places)).slice(0, places) || "0");
}
const keySign = (routeBytes: Buffer): string => // an API key signs the owner's bytes, wrapped
sign(null, Buffer.concat([tag("SIRIUS_API_KEY_SIG_V1"), Buffer.from([1]), API_PUB, routeBytes]), KEY).toString("hex");
const ownerReadBytes = (stateVersion: bigint, nonce: Buffer) =>
Buffer.concat([tag("SIRIUS_OWNER_READ_V1"), u(INDEX, 8), u(stateVersion, 8), nonce]);
function perpOrderBytes(asset: number, side: "buy" | "sell", reduceOnly: boolean, postOnly: boolean, sizeBase: bigint, priceFp: bigint, nb: bigint, na: bigint, nonce: bigint, leverage?: number): Buffer {
const body = Buffer.concat([u(INDEX, 8), ACCOUNT_ID, u(BigInt(asset), 4), Buffer.from([side === "buy" ? 0 : 1, reduceOnly ? 1 : 0, postOnly ? 1 : 0]),
u(sizeBase, 16), u(priceFp, 16), u(0n, 16), u(0n, 16), u(nb, 8), u(na, 8), u(nonce, 8)]);
if (reduceOnly) return Buffer.concat([tag("SIRIUS_PERP_ORDER_V1"), Buffer.from([1]), body]);
return Buffer.concat([tag("SIRIUS_PERP_OPEN_ORDER_V1"), Buffer.from([2]), body, u(BigInt(leverage!), 4)]);
}
const perpCancelBytes = (nonce: bigint, notAfter: bigint) =>
Buffer.concat([tag("SIRIUS_PERP_ORDER_CANCEL_V1"), Buffer.from([1]), ACCOUNT_ID, u(nonce, 8), u(notAfter, 8)]);
const perpCloid = (nonce: bigint) => // known before you send
"0x" + createHash("sha256").update(Buffer.concat([tag("SIRIUS_PERP_ORDER_CLOID_V1"), ACCOUNT_ID, u(nonce, 8)])).digest().subarray(0, 16).toString("hex");
function perpAssetId(coin: string): number {
const pinned: Record<string, number> = { BTC: 1, ETH: 2, SOL: 3, HYPE: 4 };
const k = coin.toUpperCase();
if (k in pinned) return pinned[k];
let h = 0xcbf29ce484222325n; // FNV-1a 64 of the upper-case name
for (const b of Buffer.from(k)) h = ((h ^ BigInt(b)) * 0x100000001b3n) & 0xffffffffffffffffn;
return 1024 + Number(h % (1n << 20n));
}
// ---- HTTP ----
async function call(method: "GET" | "POST", path: string, body?: unknown, idempotencyKey?: string): Promise<any> {
const headers: Record<string, string> = { "content-type": "application/json" };
if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
const r = await fetch(`${DOOR}/${path}`, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
const text = await r.text();
const json = text ? JSON.parse(text) : null;
if (!r.ok) throw new Error(`${r.status} ${json?.code} ${json?.message ?? json?.error}`);
return json;
}
async function signedRead(path: string, positionsStyle = false): Promise<any> {
const ch = await call("GET", `account/${INDEX}/state/challenge`); // single use, 120 s
const sig = keySign(ownerReadBytes(BigInt(ch.state_version), Buffer.from(ch.nonce, "hex")));
if (positionsStyle) // perp/positions names its fields differently
return call("POST", path, { account_index: Number(INDEX), nonce_hex: ch.nonce, signature_hex: sig, api_key: API_PUB.toString("hex") });
return call("POST", path, { nonce: ch.nonce, signature: sig, api_key: API_PUB.toString("hex") });
}
async function usdcBalance(): Promise<number> { // account/{index}/state answers the account's plaintext, hex
const b = Buffer.from((await signedRead(`account/${INDEX}/state`)).plaintext, "hex");
for (let i = 0; i < b.readUInt16LE(0); i++) { // entries of 48 bytes from offset 26: asset id[32], units u128
const o = 26 + 48 * i;
if (b.subarray(o, o + 32).every((x) => x === 0)) // the all-zero id is USDC, in micro-dollars
return Number(b.readBigUInt64LE(o + 32) + (b.readBigUInt64LE(o + 40) << 64n)) / 1e6;
}
return 0;
}
async function mark(coin: string): Promise<number> {
const r = await fetch(MARKET_DATA, { method: "POST", headers: { "content-type": "application/json" }, body: '{"type":"metaAndAssetCtxs"}' });
const [meta, ctxs] = await r.json();
const i = meta.universe.findIndex((a: any) => a.name === coin);
return Number(ctxs[i].markPx);
}
// ---- orders ----
let tail = 0n;
const newNonce = () => BigInt(Date.now()) * 1000n + (tail = (tail + 1n) % 1000n); // your client order id; reuse it on a retry
async function placeLimit(coin: string, side: "buy" | "sell", size: string, price: string, o: { leverage?: number; postOnly?: boolean; reduceOnly?: boolean; ttlSecs?: number } = {}) {
const { leverage, postOnly = true, reduceOnly = false, ttlSecs = 86_400 } = o;
const nonce = newNonce(), now = BigInt(Math.floor(Date.now() / 1000));
const nb = now - 30n, na = now + BigInt(ttlSecs);
const asset = perpAssetId(coin), sizeBase = fixed(size, 9), priceFp = fixed(price, 9);
const order: Record<string, unknown> = {
account_index: Number(INDEX), account_id: ACCOUNT_ID.toString("hex"), asset, side, reduce_only: reduceOnly,
rest_style: postOnly ? "alo" : "gtc", size_base: String(sizeBase), limit_price_fp: String(priceFp),
take_profit_fp: "0", stop_loss_fp: "0", not_before: Number(nb), not_after: Number(na), order_nonce: Number(nonce),
};
if (!reduceOnly) order.leverage = leverage;
const signature = keySign(perpOrderBytes(asset, side, reduceOnly, postOnly, sizeBase, priceFp, nb, na, nonce, leverage));
const response = await call("POST", "perp/order", { order, signature, api_key: API_PUB.toString("hex") }, randomUUID());
return { nonce, cloid: perpCloid(nonce), response };
}
async function cancel(nonce: bigint) {
const na = BigInt(Math.floor(Date.now() / 1000)) + 300n;
return call("POST", "perp/order/cancel", { account_id: ACCOUNT_ID.toString("hex"), order_nonce: Number(nonce), not_after: Number(na),
signature: keySign(perpCancelBytes(nonce, na)), api_key: API_PUB.toString("hex") }, randomUUID());
}
async function main() {
const m = await mark("BTC");
const price = Math.floor(m * 0.9); // 10% under the mark: rests, never fills at once
const size = (Math.ceil((12 / price) * 1e5) / 1e5).toFixed(5); // about $12 of BTC (minimum trade is $10)
console.log(`mark ${m} -> post-only buy ${size} BTC at ${price}`);
const placed = await placeLimit("BTC", "buy", size, String(price), { leverage: 2 });
console.log("placed", placed.cloid, JSON.stringify(placed.response));
console.log("orders", JSON.stringify(await signedRead(`perp/orders/${INDEX}`)));
console.log("cancel", JSON.stringify(await cancel(placed.nonce)));
console.log("positions", JSON.stringify(await signedRead("perp/positions", true)));
console.log("balance", await usdcBalance());
}
export { perpOrderBytes, perpCancelBytes, ownerReadBytes, perpCloid, perpAssetId, keySign, fixed };
if (import.meta.url === `file://${process.argv[1]}`) main().catch((e) => { console.error(e.message); process.exit(1); });
"""Sirius example bot: read the BTC mark, rest a small post-only buy below it, read it back, cancel it.
Needs Python 3.9+ and one package: pip install cryptography
Reads the five lines Settings > API keys shows when you create a key:
SIRIUS_API_URL, SIRIUS_CHAIN_ID, SIRIUS_ACCOUNT_INDEX, SIRIUS_ACCOUNT_ID, SIRIUS_API_SECRET
"""
import hashlib, json, math, os, time, urllib.error, urllib.request, uuid
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
DOOR = os.environ["SIRIUS_API_URL"].rstrip("/") + "/api/trade-api/v1"
CHAIN = os.environ["SIRIUS_CHAIN_ID"]
INDEX = int(os.environ["SIRIUS_ACCOUNT_INDEX"])
ACCOUNT_ID = bytes.fromhex(os.environ["SIRIUS_ACCOUNT_ID"])
KEY = Ed25519PrivateKey.from_private_bytes(bytes.fromhex(os.environ["SIRIUS_API_SECRET"]))
API_PUB = KEY.public_key().public_bytes(Encoding.Raw, PublicFormat.Raw)
MARKET_DATA = os.environ.get("SIRIUS_MARKET_DATA_URL", "https://api.hyperliquid.xyz/info")
# ---- bytes: every integer little-endian, every message starts with tag || 0x1F || chain_id ----
def tag(name: str) -> bytes:
return name.encode() + b"\x1f" + CHAIN.encode()
def u(v: int, n: int) -> bytes:
return v.to_bytes(n, "little")
def fixed(dec: str, places: int) -> int: # "0.00021" -> 210000 at 9 places
whole, _, frac = dec.partition(".")
return int(whole) * 10**places + int((frac + "0" * places)[:places] or 0)
def key_sign(route_bytes: bytes) -> str: # an API key signs the owner's bytes, wrapped
msg = tag("SIRIUS_API_KEY_SIG_V1") + b"\x01" + API_PUB + route_bytes
return KEY.sign(msg).hex()
def owner_read_bytes(state_version: int, nonce: bytes) -> bytes:
return tag("SIRIUS_OWNER_READ_V1") + u(INDEX, 8) + u(state_version, 8) + nonce
def perp_order_bytes(asset, side, reduce_only, post_only, size_base, price_fp, nb, na, nonce, leverage) -> bytes:
body = (u(INDEX, 8) + ACCOUNT_ID + u(asset, 4) + bytes([0 if side == "buy" else 1, int(reduce_only), int(post_only)])
+ u(size_base, 16) + u(price_fp, 16) + u(0, 16) + u(0, 16) + u(nb, 8) + u(na, 8) + u(nonce, 8))
if reduce_only:
return tag("SIRIUS_PERP_ORDER_V1") + b"\x01" + body
return tag("SIRIUS_PERP_OPEN_ORDER_V1") + b"\x02" + body + u(leverage, 4)
def perp_cancel_bytes(nonce: int, not_after: int) -> bytes:
return tag("SIRIUS_PERP_ORDER_CANCEL_V1") + b"\x01" + ACCOUNT_ID + u(nonce, 8) + u(not_after, 8)
def perp_cloid(nonce: int) -> str: # known before you send
return "0x" + hashlib.sha256(tag("SIRIUS_PERP_ORDER_CLOID_V1") + ACCOUNT_ID + u(nonce, 8)).digest()[:16].hex()
def perp_asset_id(coin: str) -> int:
pinned = {"BTC": 1, "ETH": 2, "SOL": 3, "HYPE": 4}
if coin.upper() in pinned:
return pinned[coin.upper()]
h = 0xCBF29CE484222325 # FNV-1a 64 of the upper-case name
for b in coin.upper().encode():
h = ((h ^ b) * 0x100000001B3) & 0xFFFFFFFFFFFFFFFF
return 1024 + h % (1 << 20)
# ---- HTTP ----
class SiriusError(Exception):
pass
def call(method: str, path: str, body=None, idempotency_key=None):
headers = {"content-type": "application/json"}
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
data = None if body is None else json.dumps(body).encode()
req = urllib.request.Request(f"{DOOR}/{path}", data=data, method=method, headers=headers)
try:
with urllib.request.urlopen(req, timeout=20) as r:
return json.loads(r.read() or b"null")
except urllib.error.HTTPError as e:
err = json.loads(e.read() or b"{}")
raise SiriusError(f"{e.code} {err.get('code')} {err.get('message') or err.get('error')}") from None
def signed_read(path: str, positions_style: bool = False):
ch = call("GET", f"account/{INDEX}/state/challenge") # single use, 120 s
sig = key_sign(owner_read_bytes(int(ch["state_version"]), bytes.fromhex(ch["nonce"])))
if positions_style: # perp/positions names its fields differently
return call("POST", path, {"account_index": INDEX, "nonce_hex": ch["nonce"], "signature_hex": sig, "api_key": API_PUB.hex()})
return call("POST", path, {"nonce": ch["nonce"], "signature": sig, "api_key": API_PUB.hex()})
def usdc_balance() -> float: # account/{index}/state answers the account's plaintext, hex
b = bytes.fromhex(signed_read(f"account/{INDEX}/state")["plaintext"])
for i in range(int.from_bytes(b[0:2], "little")): # entries of 48 bytes from offset 26: asset id[32], units u128
o = 26 + 48 * i
if b[o:o + 32] == bytes(32): # the all-zero id is USDC, in micro-dollars
return int.from_bytes(b[o + 32:o + 48], "little") / 1e6
return 0.0
def mark(coin: str) -> float:
req = urllib.request.Request(MARKET_DATA, data=b'{"type":"metaAndAssetCtxs"}', headers={"content-type": "application/json"})
meta, ctxs = json.loads(urllib.request.urlopen(req, timeout=20).read())
i = [a["name"] for a in meta["universe"]].index(coin)
return float(ctxs[i]["markPx"])
# ---- orders ----
_tail = 0
def new_nonce() -> int: # your client order id; reuse it on a retry, never invent a new one
global _tail
_tail = (_tail + 1) % 1000
return int(time.time() * 1000) * 1000 + _tail
def place_limit(coin, side, size, price, leverage=None, post_only=True, reduce_only=False, ttl_secs=86_400):
nonce, now = new_nonce(), int(time.time())
nb, na = now - 30, now + ttl_secs
asset, size_base, price_fp = perp_asset_id(coin), fixed(size, 9), fixed(price, 9)
order = {"account_index": INDEX, "account_id": ACCOUNT_ID.hex(), "asset": asset, "side": side,
"reduce_only": reduce_only, "rest_style": "alo" if post_only else "gtc",
"size_base": str(size_base), "limit_price_fp": str(price_fp), "take_profit_fp": "0", "stop_loss_fp": "0",
"not_before": nb, "not_after": na, "order_nonce": nonce}
if not reduce_only:
order["leverage"] = leverage
sig = key_sign(perp_order_bytes(asset, side, reduce_only, post_only, size_base, price_fp, nb, na, nonce, leverage))
resp = call("POST", "perp/order", {"order": order, "signature": sig, "api_key": API_PUB.hex()}, idempotency_key=str(uuid.uuid4()))
return {"nonce": nonce, "cloid": perp_cloid(nonce), "response": resp}
def cancel(nonce: int):
na = int(time.time()) + 300
body = {"account_id": ACCOUNT_ID.hex(), "order_nonce": nonce, "not_after": na,
"signature": key_sign(perp_cancel_bytes(nonce, na)), "api_key": API_PUB.hex()}
return call("POST", "perp/order/cancel", body, idempotency_key=str(uuid.uuid4()))
def main():
m = mark("BTC")
price = math.floor(m * 0.90) # 10% under the mark: rests, never fills at once
size = math.ceil(12 / price * 1e5) / 1e5 # about $12 of BTC (minimum trade is $10)
print(f"mark {m} -> post-only buy {size:.5f} BTC at {price}")
placed = place_limit("BTC", "buy", f"{size:.5f}", str(price), leverage=2)
print("placed", placed["cloid"], json.dumps(placed["response"]))
print("orders", json.dumps(signed_read(f"perp/orders/{INDEX}")))
print("cancel", json.dumps(cancel(placed["nonce"])))
print("positions", json.dumps(signed_read("perp/positions", positions_style=True)))
print("balance", usdc_balance())
if __name__ == "__main__":
main()
7. What the venue sees, and what stays private
- The venue sees Sirius. Sirius places your order at the venue from its own account, which carries the orders of every Sirius user. The venue sees that order: market, side, size, price and time. A resting limit sits on the venue's public book as a Sirius order while it rests.
- The venue does not see you. Not your name, your wallet, your Sirius account, your balance or your other positions. Your requests reach Sirius's servers, never the venue.
- Other people cannot read your account. Every read of your balance, positions, orders or fills needs a signature from your account key or one of your API keys.
- Sirius runs the engine that executes your orders, so the engine sees them. Every state change is proven and verified on Solana.
Integrate Sirius
Private transfers, trades, and swaps for your users. Sirius gives your users private balances backed by USDC. They can hold them, send them, and trade perps and spot with them. Only the account owner can read a balance. Every transaction is proven and verified on Solana. You reach all of it through a signed HTTP API.
What is live today
-
Trading API: perps and spot by API keyLive
Trade from your own servers with an API key. Place, cancel and protect orders, open and close at market, and run a TWAP. Read positions, orders, balances and fills. A key can trade and read. It can never move money out. See API keys.
-
Private perpsLive
Perpetuals with leverage up to each market's own maximum (40x on BTC today; the app shows each market's limit), take-profit and stop-loss, scale orders and TWAP. No one can see your positions.
-
Private spot and swapsLive
Buy and sell listed assets with your USDC balance, at a live market price. Limit orders work on spot too.
-
Private transfers & holdsLive
Move a balance between accounts, or hold one privately.
-
Partner-listed assetsBy arrangement
Bring your own token or product, and your users hold and trade it privately. We set up each listing with you. See List your own asset.
-
Agent payments over x402 and agent accountsOn request
Let agents pay over standard x402, privately. Give each agent its own account with limits you set. Ask us to switch both on for your app.
The API at a glance
The API has two base URLs, which these docs call doors. Each request is signed with an Ed25519 key. There are no shared secrets.
| Door | Who signs | What it does |
|---|---|---|
/api/trade-api/v1 | an API key the account owner created | Trade perps and spot, set protection, read positions, orders, balances and fills, stream account events. No money out, ever. |
/api/txproxy/api | the account's own key | Everything the owner can do: register and revoke API keys, transfer, withdraw and claim to Solana, owner reads. |
GET /api/tx/:hash/receipt | nobody | Confirmation status of a submitted transaction. |
Networks and access
Sirius runs on Solana mainnet. Every signature includes the chain id, so a signature made for one network cannot be used on another.
| Mainnet | |
|---|---|
| Trading door | https://app.siriusprotocol.xyz/api/trade-api/v1 |
| Owner door | https://app.siriusprotocol.xyz/api/txproxy/api (signed-in session) |
| Chain id | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d |
- The trading door is open. It answers only requests signed by a registered API key. Any route not on its list returns 404.
- Any account can create a key in Settings, API keys, once it has made its first deposit.
- The owner door needs a signed-in app session. Anyone can sign in. The account owner creates keys in the app (Settings, API keys).
export SIRIUS_DOOR="https://app.siriusprotocol.xyz/api/trade-api/v1" # API key requests
export SIRIUS_OWNER="https://app.siriusprotocol.xyz/api/txproxy/api" # owner-signed requests
curl -s "$SIRIUS_DOOR/config" # public: markets, minimums, fees, limits
Quickstart
This walks you to your first signed order. You open an account, get a key, then place, read and cancel an order that rests on the book. Until the SDK is out, sign each request with the schemes in Signing a request.
1. An account and a key
- Open the app Go to
https://app.siriusprotocol.xyz, sign in and fund the account (see Fund a user). - Create the key Go to Settings, API keys, Create API key. Choose the trade and read permissions, an expiry, and your server's IP. The app shows the secret once. Keep it on your server, never in a browser bundle.
2. Check the door
curl -s -o /dev/null -w '%{http_code}\n' "$SIRIUS_DOOR/config" # 200
curl -s "$SIRIUS_DOOR/account/<index>/state/challenge" # {"nonce": ...}
3. Place, read and cancel an order
// Sirius TypeScript SDK (coming soon): SiriusTradingClient, Ed25519Signer, AccountStream, TradingApiError
const c = new SiriusTradingClient({
network: "mainnet",
auth: "apiKey",
accountIndex: BigInt(process.env.SIRIUS_ACCOUNT_INDEX!),
accountId: process.env.SIRIUS_ACCOUNT_ID!, // 64 hex: the account's public key
signer: new Ed25519Signer(process.env.SIRIUS_API_SECRET!),
});
const mid = Number(await c.mid("BTC"));
const price = String(Math.floor(mid * 0.6)); // far below the market: it rests
const o = await c.placePerpOrder({ market: "BTC", side: "buy", size: "0.0003", price, leverage: 3 });
console.log(o.cloid); // known before sending
console.log(await c.orderStatus(o.cloid));
console.log(await c.cancel(o));
console.log(await c.positions(), await c.balances());
The SDK throws typed errors: catch (e) { if (e instanceof TradingApiError) console.log(e.status, e.code) }.
API keys
An API key lets your servers trade and read for an account without holding the account's own key. It is a separate Ed25519 key pair that the account owner registers.
- A key can trade, read, or both. No key can withdraw, transfer, claim, deposit or create another
key. Those permissions do not exist, and the money-out routes ignore
api_key. - A key expires within 365 days. You can also give it an IP allowlist (up to 16 exact addresses) and its own caps per order and per rolling 24 hours.
- The fee on every trade, by key or in the app, is published at siriusprotocol.xyz/fees. It is shown before you confirm.
- An account can have up to 10 active keys. The owner can revoke any key. A key can always revoke itself.
- Create a key in the app (Settings, API keys). Or create it in code with the SDK's
registerApiKeyin owner mode, through the owner door. It sends the same signed request the app sends.
Signing a request
To sign a trading request with an API key, start from the domain tag. Every signed message starts
with a domain tag that includes the network: domain_tag(T) = T || 0x1F || chain_id
(ASCII). All integers are little-endian. A key signature wraps the exact bytes the owner would sign
for the same action:
key_message = domain_tag("SIRIUS_API_KEY_SIG_V1") || 0x01 || api_pubkey[32] || route_bytes
signature = Ed25519(api_secret, key_message) // 64 bytes, sent as 128 hex
route_bytes = the owner's message for that action: same tag, the OWNER's account_id, same nonce
The body carries "api_key": "<key public key, 64 hex>" and the
signature. An owner signing directly sends route_bytes
alone and no api_key.
Schemes you sign
| Tag | Layout after the domain tag | Used by |
|---|---|---|
SIRIUS_PERP_OPEN_ORDER_V1 | 02, account_index u64, account_id[32], asset u32, side u8, reduce_only u8 (0), rest_style u8 (0 gtc, 1 alo), size_base u128, limit_price_fp u128, tp_fp u128, sl_fp u128, not_before u64, not_after u64, order_nonce u64, leverage u32 | opening limit order |
SIRIUS_PERP_ORDER_V1 | 01, the same body with reduce_only = 1, no leverage | reduce-only limit |
SIRIUS_PERP_ORDER_CANCEL_V1 | 01, account_id[32], order_nonce u64, not_after u64 | perp cancel |
SIRIUS_USER_PERP_OPEN_V1 + SIRIUS_USER_SLIPPAGE_V1 | market open, plus a required signed slippage bound when signed by a key | market open |
SIRIUS_USER_PERP_CLOSE_V1 | account_index u64, account_id[32], challenge_nonce[32], asset_id u32 | market close |
SIRIUS_PERP_TRIGGER_V1 / _REVOKE_V1 / _AMEND_V1 | stop-loss and take-profit: set, cancel, move | protection |
SIRIUS_PERP_TWAP_V1 / _CANCEL_V1 | TWAP order (sign the preview's disclosure_id) and its cancel | TWAP |
SIRIUS_SPOT_ORDER_V1 / _CANCEL_V1 | 01, account_index u64, account_id[32], asset u32, side u8, rest_style u8, size_micro_coin u128, limit_price_fp u128, not_before u64, not_after u64, order_nonce u64 | spot limit and cancel |
SIRIUS_SPOT_TRIGGER_V1 | spot entry, take-profit and stop-loss (not available yet) | spot triggers |
SIRIUS_OWNER_READ_V1 | account_index u64, state_version u64, nonce[32] | every signed read, and the stream |
SIRIUS_API_KEY_REGISTER_V2 / SIRIUS_API_KEY_REVOKE_V1 | register a key with its own caps (owner) / revoke (owner or the key itself) | key management |
The SDKs below build every scheme byte for byte, and test against the engine's own signing vectors.
Your order_nonce is your client order id. The order's
cloid is derived from it, so you know the cloid before you send.
A resting order's not_after may be up to 30 days ahead. A cancel,
registration or revocation may set it at most 600 seconds ahead. Set not_before = now - 30
to allow for clock skew.
Routes
Paths are relative to the trading door URL. The Perm column shows the key permission each route needs: T for trade, R for read.
| Route | Perm | What it does |
|---|---|---|
GET config | Markets, minimums, fee schedule, limits. Public. | |
GET account/{index}/state/challenge | Single-use read challenge, valid 120 s. | |
POST perp/order, perp/order/cancel | T | Resting limit order (gtc or post-only) and its cancel. |
GET perp/order/{cloid} | One resting order. | |
POST perp/open, perp/close | T | Market open sized by margin and leverage, with a signed slippage bound; market close of the whole position. |
POST perp/protection, perp/protection/pair, perp/protection/cancel, perp/trigger/amend | T | Stop-loss and take-profit: set, set both, cancel, move. By API key on mainnet these answer ENGINE_PROTECTIONS_KEY_UNSUPPORTED today; see Orders. |
POST perp/twap, perp/twap/cancel; GET perp/twap/preview, perp/twap/{ref} | T | TWAP order, preview and status. |
POST spot/order, spot/order/cancel | T | Spot limit order and cancel. For a market buy, send a marketable limit at your worst price. |
POST spot/trigger, spot/tpsl, spot/trigger/cancel, spot/trigger/amend | T | Spot entry, take-profit and stop-loss. Not available yet |
POST perp/positions, perp/orders/{index}, perp/protections/{index}, spot/orders/{index}, spot/triggers/{index} | R | Signed reads of positions, orders and protections. |
POST account/{index}/state, account/{index}/trades | R | Balances; fills and funding history, paginated. |
POST apikeys/list/{index}, apikeys/revoke | R | Your keys, caps and usage; a key revokes itself. |
GET apikeys/stream/{index} | R | Server-Sent Events: snapshot, then positions, orders, balances and fills as they change. Resumes with Last-Event-ID. |
To retry safely, send an Idempotency-Key header on every trading POST. If
the first request succeeded within 24 hours, the retry gets the original answer with
Idempotent-Replayed: true. Nothing is sent twice.
Reuse the same order_nonce on a retry. Never make a new one.
SDKs
SDK coming soon. The SDKs are not on npm or PyPI yet, and any package there that claims to be one is not ours. Until they are, sign requests yourself with the HTTP API reference above: the signing schemes and every route. The examples below show what the SDKs will look like.
The TypeScript and Python clients cover every route above. They support API key and owner modes, key registration and revocation, limit and market orders, take-profit and stop-loss, TWAP, spot triggers (not available yet), reads, the account stream, typed errors and safe retries.
Both SDKs test against the engine's own signing vectors. Each reads the lines Settings shows when you
create a key: SiriusTradingClient.fromEnv() in TypeScript,
Client.from_env() in Python.
await c.openMarket({ market: "ETH", side: "buy", leverage: 2, marginUsd: "10", maxSlippageBps: 100 });
await c.setTpsl("ETH", "4200", "2900"); // take-profit and stop-loss
console.log(await c.protections());
await c.closePosition("ETH"); // market close of the whole position
for await (const fill of c.iterTrades({ limit: 50 })) console.log(fill);
const s = new AccountStream(c).subscribe("fills", console.log).subscribe("positions", console.log);
await s.run({ maxEvents: 5 }); // SSE, resumes with Last-Event-ID
await c.revokeApiKey(); // a key can always revoke itself
# Sirius Python SDK (coming soon): Client, Ed25519Key
c = Client("mainnet", account_index, account_id_hex, Ed25519Key.from_hex(api_secret_hex), auth="api_key")
o = c.place_perp_limit("BTC", "buy", "0.0003", "45000", leverage=3)
print(o["cloid"], c.order_status(o["cloid"]))
print(c.cancel_perp(o["nonce"]), c.positions())
Errors and limits
Every error to a key-signed request has the body
{"error", "message", "code", "retryable"} and the header
X-Sirius-Error-Code. Write your logic against code.
Show message to people. New codes may be added. Existing codes are never removed.
| Code | Status | Meaning |
|---|---|---|
KEY_NOT_REGISTERED | 401 | Unknown key, or a key for the other network. |
KEY_REVOKED / KEY_EXPIRED | 401 | Permanent: make a new key. |
ACCOUNT_NOT_ENABLED | 401 | API keys are not switched on for this account yet. |
IP_NOT_ALLOWED | 401 | Client IP is not on the key's allowlist. |
BAD_SIGNATURE | 400/401 | The signature does not verify over these bytes. |
CHALLENGE_INVALID | 401 | Read challenge unknown, used or expired: fetch a fresh one. |
RATE_LIMITED | 429 | Over the key's per-minute budget. Retry after Retry-After. |
ORDER_CAP_EXCEEDED / DAY_CAP_EXCEEDED | 400/429 | Over the per-order or rolling 24 hour cap. |
DUPLICATE_ORDER | 400 | This order nonce already rests, was cancelled or filled. |
SLIPPAGE_REQUIRED / SLIPPAGE_EXCEEDED | 400/422 | Market open bound missing or breached. |
LEVERAGE_TOO_HIGH / MIXED_LEVERAGE | 400 | Above the market's maximum, or conflicts with the open position. |
INSUFFICIENT_BALANCE | 400/422 | Not enough spendable balance. |
CONFLICT | 409 | For example a market close with no open position in that market. |
VENUE_UNAVAILABLE / SERVICE_UNAVAILABLE | 400/503 | Retryable. |
| Limit | Value |
|---|---|
| Requests per key | A per-minute budget per key; read yours from apikeys/list |
| Per-order and rolling 24 hour notional | The lower of the network cap and the key's own cap |
| Keys | 10 active per account, 365 days at most |
| Streams | 2 per key, 6 hours each, then reconnect |
| Read challenges | 64 per client IP and a few per account: fetch one per read and use it at once |
| Minimum trade | $10 |
Accounts
Choose how your users' money is held. The three terms below are used everywhere else in these docs.
Two integration models
-
House accountSimplest
You own one Sirius account. You track each user's share in your own ledger. Every hold, transfer and swap runs from your account. Outsiders cannot see it. You manage no per-user keys. One account has one nonce sequence, so send its transactions one at a time.
-
Per-user accountsSelf-custodial
Each user gets their own key pair (see Create an account key in code). Only that key can spend the user's balance, so your users hold their own funds. Sirius sees account ids, never your user list.
Both models work today. You can start with a house account and move users to their own keys later.
Three terms
account_id- The account's Ed25519 public key (32 bytes). Only the matching secret key can spend from the account. In the house model that key is yours. In the per-user model it stays with the user and you never hold it. Sirius rejects a spend signed by anyone other than the account owner.
- SSD
- The account's USDC-backed balance, the base asset with
asset_id 0. A deposit credits SSD. A balance is a count of shares. Its USD value isshares * r_global / 1e9 / 1e6. Swaps move between SSD and a listed asset. Each listed asset has its ownasset_id. account_index- A number the account gets on its first deposit. Most endpoints take it. An account that has never
been funded has no index.
GET /api/account/by-id/:hexlooks up the index for anaccount_id.
Create an account key in code
Use this to create per-user accounts yourself. Users who sign in through the app get their key there instead.
An account is an Ed25519 key pair, and the public key is the account_id.
The public key, read as a little-endian number, must be below the BN254 field modulus. About 4 in 5
random keys fail this check. So generate keys in a loop until one passes. That takes about five tries
on average.
Store the secret key safely. It is the only key that can spend from the account.
import { getPublicKeyAsync, utils } from "@noble/ed25519";
// Accounts must be canonical BN254 field elements.
const BN254_R =
21888242871839275222246405745257275088548364400416034343698204186575808495617n;
const leToBig = (b: Uint8Array) => {
let x = 0n;
for (let i = b.length - 1; i >= 0; i--) x = (x << 8n) | BigInt(b[i]);
return x;
};
async function createAccount() {
for (;;) {
const secret = utils.randomPrivateKey(); // 32-byte secret
const accountId = await getPublicKeyAsync(secret); // 32-byte account_id
if (leToBig(accountId) < BN254_R) return { secret, accountId };
}
}
Fund a user
Use this to put a starting balance in a user's account. The user deposits USDC in the app's deposit sheet. An API key cannot deposit, so send your user to the app.
- From Solana, the user sends USDC from their own Solana wallet.
- From BNB Chain, the user signs in with a BNB Chain wallet and deposits from it. The app bridges it to Solana.
- From Hyperliquid, the user links their Hyperliquid address in the app. Then they send USDC from their Hyperliquid Spot balance to the account the app shows. It is credited in minutes.
- The deposit sheet lists any other chains it accepts today.
The deposit is credited to the account as SSD. The first deposit also gives the account its
account_index.
Every deposit must be at least $12. The first deposit has a one-time $2 account fee. Later deposits have no fee.
# Once credited, resolve the assigned index (owner door)
curl -s "$SIRIUS_OWNER/account/by-id/<account_id hex>"
Read a balance
Use this to show a user their balance. It also gives you the spend nonce you need before you sign a transfer, swap or withdrawal. The spend nonce is a number that each signed spend must carry. A stale one is rejected.
Balances are private. Sirius returns a balance and nonce only to a request signed by the account
owner, or by one of its API keys with read permission. Fetch a single-use challenge, sign
SIRIUS_OWNER_READ_V1 || account_index || state_version || nonce, and post it.
# 1. A single-use challenge, valid 120 s
curl -s "$SIRIUS_DOOR/account/7/state/challenge"
# -> { "account_index": 7, "exists": true, "domain": "SIRIUS_OWNER_READ_V1",
# "nonce": "<64 hex>", "state_version": 11, "ttl_secs": 120 }
# 2. Sign it and read the balances
curl -s -X POST "$SIRIUS_DOOR/account/7/state" \
-H "Content-Type: application/json" \
-d '{ "nonce": "<64 hex>", "signature": "<128 hex>", "api_key": "<64 hex>" }'
The SDKs do both steps in one call: c.balances(). Put the spend
nonce you read into the next signed transfer, swap or withdrawal.
Private transfer
Use this to move a balance from one user to another. A transfer moves shares between two accounts. A balance that stays in an account is a private hold: only the owner can read it.
- Resolve indices
GET /api/account/by-id/:hexfor both sender and recipient. - Read the sender nonce From Read a balance.
- Sign The sender's key signs the Transfer canonical bytes (Signing).
- Submit
POST /api/tx/transferwith theauthobject. - Confirm Poll the receipt (Confirming).
curl -s -X POST "$SIRIUS_OWNER/tx/transfer" \
-H "Content-Type: application/json" \
-d '{
"from_index": 7,
"to_index": 42,
"from_account_id": "<alice account_id hex>",
"to_account_id": "<bob account_id hex>",
"amount": "1000000",
"nonce": 3,
"auth": {
"sender_pubkey": "<alice account_id hex>",
"signature": "<128 hex chars>"
}
}'
# -> { "success": true, "message": "queued", "mempool_size": 12, "tx_hash": "0x..." }
A Transfer names from_index and to_index, so
Sirius can see who paid whom. Sirius is not a mixer. Do not tell your users that transfers
are unlinkable.
Private swap
Use this to let a user swap between their SSD balance and a listed asset. The price comes from an oracle. Every swap pairs SSD with exactly one asset. To go from one asset to another, swap through SSD.
To offer swaps in an asset that is not listed yet, see List your own asset.
-
Get a quote
GET /api/quote?asset=sbtc&side=buy, whereassetis the wire symbol (sbtc,seth,ssol) or the numericasset_id, andsideisbuyorsell. It returnsprice_fp, the price for your side (ask for a buy, bid for a sell), as a u128 at 1e9 fixed-point. Use it in the next step. If the oracle is stale or missing, the quote returns an error, not a price. The quote also carries your fee rate and the market's minimum trade. -
Build the Trade
Set
oracle_price_fpto the quote'sprice_fp. A price for the wrong side, or too far from the market, is rejected. The minimum trade is $10. Trade right after you quote and neither will happen. - Sign The user's key signs the Trade canonical bytes (Signing).
- Submit
POST /api/tx/tradewith theauthobject. - Confirm Poll the receipt (Confirming).
# 1. Quote a buy of BTC (wire symbol: sbtc)
curl -s "$SIRIUS_OWNER/quote?asset=sbtc&side=buy"
# -> {
# "asset": 1,
# "side": "buy",
# "mid_fp": 64006442500000,
# "bid_fp": 64006442500000,
# "ask_fp": 64006442500000,
# "price_fp": 64006442500000, // use this as oracle_price_fp
# "oracle_age_secs": 3,
# "min_trade_usd": 10.0,
# ...
# }
# 2. Submit the signed trade (oracle_price_fp = price_fp from the quote)
curl -s -X POST "$SIRIUS_OWNER/tx/trade" \
-H "Content-Type: application/json" \
-d '{
"account_index": 7,
"account_id": "<account_id hex>",
"from_asset": 0,
"to_asset": 1,
"input_amount": "5000000",
"oracle_price_fp": "64006442500000",
"oracle_timestamp": 1737000000,
"nonce": 4,
"auth": {
"sender_pubkey": "<account_id hex>",
"signature": "<128 hex chars>"
}
}'
Withdraw
Use this to send a user's balance back out to Solana.
POST /api/tx/withdraw burns shares and queues a withdrawal to the Solana
address in l1_destination. The user's key signs it, the same way as a transfer.
curl -s -X POST "$SIRIUS_OWNER/tx/withdraw" \
-H "Content-Type: application/json" \
-d '{
"account_index": 7,
"account_id": "<account_id hex>",
"amount": "1000000",
"l1_destination": "<32-byte Solana address hex>",
"nonce": 5,
"auth": {
"sender_pubkey": "<account_id hex>",
"signature": "<128 hex chars>"
}
}'
The withdrawal debits the account. Sirius then owes that amount to the Solana address. Sirius proves transactions in batches called epochs. Once the epoch with the withdrawal is proven, the USDC can be claimed on Solana.
To claim, call tx/claim-exit. It returns a Solana transaction, with the
fee sponsored by default. The destination wallet signs it, then you send it to
tx/claim-exit/submit. The app runs this claim for your users.
- The fee is 0.20% (20 bps), taken from the payout. A $50 withdrawal pays out $49.90.
- The minimum withdrawal is $2.
- A withdrawal arrives in minutes, once the funds return from the venue. In the app, a user can also send it on to BNB Chain.
- Only the account's own key can sign a withdrawal, transfer or claim. An API key can never move money out.
Trading fees are published at siriusprotocol.xyz/fees. Trading also earns rewards: see siriusprotocol.xyz/points.
Money in and out
| Action | Fee | Minimum |
|---|---|---|
| First deposit | $2, once | $12 |
| Later deposits | None | $12 |
| Transfers between accounts | None | |
| Withdraw to Solana | 0.20%, deducted from the payout | $2 |
| Trade | See siriusprotocol.xyz/fees | $10 |
List your own asset or product By arrangement
Use this to offer your own token or product to your users next to the listed markets. It can be a fund share, a wrapped position, a real-world asset or a token of your own. Its backing must be verifiable.
Contact us to arrange a listing for your asset. There is no self-serve listing. We work out each one with you.
To start, tell us:
- the asset and its unit;
- where its reserve is held;
- how the reserve can be verified: an onchain reserve, a custodian attestation or a proof of reserves;
- where its price comes from: a market venue, a NAV or a fixed peg.
Agent payments over x402 On request
Use this to let an agent pay for something without making the amount public.
Ask us and we'll switch it on for your app. Use the request-access form.
x402 is an open payment standard built on
HTTP 402 Payment Required. A server answers a request with what it costs. The
client pays, then retries with proof of payment in a header. x402 defines this exchange. It leaves the
actual payment to a facilitator, a service that settles it on a chain.
Sirius is that facilitator. The agent uses standard x402. The payment settles as a Sirius transfer, so no one can see the amount or the balance. The transfer is proven and verified on Solana.
Once it is on for your app, we send you the facilitator URL ($SIRIUS_FACILITATOR below) and the
x402 client and paywall packages. The agent's code stays an ordinary x402 client.
The flow
- Agent requests a resource Your server answers
402with payment requirements naming the Sirius scheme. - Agent pays It signs a Sirius transfer and puts the payload in the
X-PAYMENTheader. - Facilitator verifies It checks the signature, the nonce and the balance before anything settles.
- Facilitator settles The transfer goes through on Sirius. It is then proven and verified on Solana.
- Server returns the resource With the settlement receipt in
X-PAYMENT-RESPONSE.
The facilitator endpoints
The facilitator has three endpoints. supported is public. The other two
carry the payer's signature inside the payload.
| Endpoint | What it does |
|---|---|
GET /api/x402/supported | Scheme and network discovery. Public. |
POST /api/x402/verify | Check a payment without settling it. |
POST /api/x402/settle | Verify, then settle as a Sirius transfer. |
curl -s "$SIRIUS_FACILITATOR/api/x402/supported"
# -> { "kinds": [ { "x402Version": 1,
# "scheme": "sirius-private",
# "network": "solana" } ] }
The SDK
The Sirius x402 SDK covers both sides: the agent that pays and the server that charges. It is not published yet. The paywall import has no signing code, so a server that never signs ships no crypto code.
// Sirius x402 SDK (coming soon): siriusFetch, readSettlement
const res = await siriusFetch("https://api.example.com/v1/inference", {
account: { privateKey: process.env.AGENT_SECRET_KEY }, // 32-byte Ed25519 seed
apiBase: process.env.SIRIUS_FACILITATOR,
maxAmount: 50000n, // refuse anything dearer, sign nothing
method: "POST",
body: JSON.stringify({ prompt }),
});
const data = await res.json();
const receipt = readSettlement(res); // { success, transaction, network, payer }
On a 402, it reads the requirements and picks the
sirius-private offer. It looks up the payer's index and nonce, signs a
transfer, and sends the request again with X-PAYMENT.
It pays at most once per call. If the retry also gets a 402, it returns that response and does not pay again.
// Sirius x402 SDK, paywall part (coming soon): siriusPaywall
const paywall = siriusPaywall({
price: "$0.02", // or base units: "20000"
payTo: process.env.SIRIUS_ACCOUNT_ID, // your account_id hex
facilitator: process.env.SIRIUS_FACILITATOR,
network: "solana",
});
app.get("/v1/inference", paywall.middleware, (req, res) => {
res.json({ answer: 42 }); // only runs once the payment has settled
});
middleware is a thin wrapper over handle, which
takes data and returns data, so it works with any framework.
The paywall always sends the facilitator its own requirements, never the client's copy. So a client cannot pay itself, or pay less, and have the receipt accepted.
The payment payload
Under the SDK, the sirius-private payload is a signed Sirius transfer. It
has the same fields and the same signing bytes as a Private transfer. If you
can already send a transfer, you need no new signing code for x402.
curl -s -X POST "$SIRIUS_FACILITATOR/api/x402/settle" \
-H "Content-Type: application/json" \
-d '{
"x402Version": 1,
"paymentPayload": {
"scheme": "sirius-private",
"network": "solana",
"payload": {
"from_index": 7,
"to_index": 42,
"from_account_id": "<agent account_id hex>",
"to_account_id": "<your account_id hex>",
"amount": "20000",
"nonce": 3,
"auth": {
"sender_pubkey": "<agent account_id hex>",
"signature": "<128 hex chars>"
}
}
},
"paymentRequirements": {
"scheme": "sirius-private",
"network": "solana",
"maxAmountRequired": "20000",
"payTo": "<your account_id hex>",
"asset": "0",
"resource": "https://api.example.com/v1/inference"
}
}'
# -> { "success": true,
# "transaction": "<l2 tx hash hex>",
# "network": "solana",
# "payer": "<agent account_id hex>" }
/api/x402/verify takes the same body. It returns
{ "isValid": true, "payer": "..." }, or
{ "isValid": false, "invalidReason": "..." }, with HTTP 200 either way. A
false result is an answer, not a transport error.
Settlement returns a Sirius transaction hash. Poll
GET /api/tx/:hash/receipt if you need to know it is final.
What gets checked
-
The payment is yours
The recipient must match
payTo, so a client cannot pay itself and show the receipt as proof. The amount must be at leastmaxAmountRequired. -
The payer authorised it
The facilitator checks the Ed25519 signature over the transfer bytes the same way the transfer route does. An x402 payment is never easier to authorise than a plain transfer. The facilitator holds no funds. It cannot move money the payer did not sign for.
-
It can actually settle
The nonce, the balance and the per-account submission limit are checked before the payment is sent.
verify is a check, not a lock. It reads the balance and nonce at that
moment. Another spend from the same account can make the payment fail between
verify and settle. Release the resource only
after a successful settle.
Agent accounts On request
Use this to give an agent its own money without giving it yours. An agent account is an ordinary Sirius account that you register under your own account, the parent. It has its own key and signs its own transactions. It can spend only within the limits you set. You can revoke it.
Ask us and we'll switch it on for your app. Use the request-access form.
First fund the agent's account_id so the account exists. Then register it
with your limits. We run the registration for your parent account (the call below), and your parent
key's signature is checked as well.
Limits are in USD and can be fractions, so you can set limits for very small payments.
curl -s -X POST "$SIRIUS_FACILITATOR/api/agent/create" \
-H "Content-Type: application/json" \
-d '{
"parent_index": 7,
"agent_pubkey": "<agent account_id hex>",
"limits": {
"daily_notional_usd": 500,
"max_payment_usd": 5,
"allowed_assets": [0]
}
}'
# -> { "success": true, "agent_index": 118, "revocable": true, "persisted": true }
POST /api/agent/revoke stops the agent from spending, starting with its
next spend. A revoked agent cannot be restored.
GET /api/agent/:index returns the agent's limits, what it has spent in the
current window, and whether it is revoked. GET /api/agent/list/:parent_index
lists the agents under a parent.
-
Limits are checked first
Sirius refuses a payment over the limit before it is queued. You do not rely on the agent to behave. The check runs after the signature check, so a forged request cannot use up an agent's budget.
-
Agents run in parallel
Each agent account has its own nonce sequence. Agents running in parallel do not wait for each other, as they would on one shared house account.
-
Rolling window
daily_notional_usdcovers a rolling 24 hours, not a calendar day. Registering an agent again updates its limits but keeps the current window, so posting again does not reset what it has spent. -
An activity record
Sirius records every payment, withdrawal or swap it allows or refuses for an agent. The parent reads the record by signing a single-use challenge with its own key. Each entry has the time, the asset and amount, the USD value, the counterparty, the transaction hash, and whether it was allowed. A refusal includes the reason. A parent can read only its own agents.
# 1. get a single-use challenge for the parent
curl -s "$SIRIUS_FACILITATOR/api/agent/activity/challenge/7"
# -> { "nonce": "<hex>", ... }
# 2. sign it with the PARENT key and read the agent's record
curl -s -X POST "$SIRIUS_FACILITATOR/api/agent/118/activity" \
-H "Content-Type: application/json" \
-d '{ "nonce": "<hex>", "signature": "<128 hex chars>" }'
# -> { "entries": [ { "at": ..., "kind": "spend", "asset_id": 0,
# "amount": "20000", "usd": "0.02", "to_index": 42,
# "tx_hash": "<hex>", "allowed": true } ],
# "truncated": false, "durable": false, "recorded_since": ... }
What the limits cover
Limits apply on every route where the agent's own key moves value.
| Route | What counts against the limit |
|---|---|
POST /api/tx/transfer | the amount transferred |
POST /api/tx/withdraw | the amount withdrawn. A withdrawal to Solana uses the same daily budget as a payment. |
POST /api/tx/trade | the USD notional of the leg being sold. Both the asset sold and the asset bought must be in allowed_assets. |
POST /api/perp/open | the margin posted, not the leveraged notional |
POST /api/x402/settle | the amount settled. /verify reports the verdict without consuming budget. |
daily_notional_usd limits everything the agent moves, not only payments.
Swaps and perp margin count against it. Set a trading agent's limit to the volume it will trade.
POST /api/perp/close has no limit, because it returns value to the agent.
A revoked agent can always close an open position. Revoking stops new spending and never traps funds.
Sirius applies the limits before it accepts a transaction. Sirius keeps the activity record and gives it to the parent on request. Neither is part of the zero-knowledge proof.
The record holds the latest 256 entries per agent and says when it dropped older ones. It clears when the service restarts, so save anything you need to keep.
Spend signing
The account's own key signs every transfer, swap and withdrawal. (Trading by API key uses the schemes in Signing a request.)
Every spend works the same way. Build the transaction's canonical bytes, using the layout
below. Sign them with the account's Ed25519 secret key. Put the signature in the
auth object. The layout is the complete spec, so you can build it in any
language.
{
"sender_pubkey": "<64 hex chars = the account's 32-byte Ed25519 pubkey>",
"signature": "<128 hex chars = the 64-byte Ed25519 signature>"
}
The server requires sender_pubkey == account_id for the transaction (for a
Transfer, the from_account_id). So a user can only sign for their own
account.
The canonical layout
All integers little-endian, fields concatenated with no separators:
"SIRIUS_L2_V1" (12 ASCII bytes) || 0x1F || chain_id (ASCII) || tx_type:u8 || <per-variant fields>
chain_id = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
The version tag SIRIUS_L2_V1
(hex 5349524955535f4c325f5631), the separator byte and the chain id tie
every signature to one network.
The tx_type byte stops a signature for one kind of transaction being
reused for another. Transfer is 1, Withdraw is 2, Trade is 4.
Per-variant fields
Transfer (tx_type = 1)
from_index : u64 (8 LE)
to_index : u64 (8 LE)
from_account_id : [u8; 32]
to_account_id : [u8; 32]
amount : u128 (16 LE)
nonce : u64 (8 LE)
Withdraw (tx_type = 2)
account_index : u64 (8 LE)
account_id : [u8; 32]
amount : u128 (16 LE)
l1_destination : [u8; 32]
nonce : u64 (8 LE)
Trade (tx_type = 4)
account_index : u64 (8 LE)
account_id : [u8; 32]
from_asset : u32 (4 LE)
to_asset : u32 (4 LE)
input_amount : u128 (16 LE)
oracle_price_fp : u128 (16 LE)
oracle_timestamp : u64 (8 LE)
nonce : u64 (8 LE)
Worked example: Transfer
A complete encoder that needs only @noble/ed25519:
import { sign } from "@noble/ed25519";
const CHAIN_ID = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"; // Solana mainnet
const DOMAIN = new TextEncoder().encode("SIRIUS_L2_V1\x1f" + CHAIN_ID); // tag, 0x1F, chain id
function u64le(n: bigint) { const b = new Uint8Array(8); new DataView(b.buffer).setBigUint64(0, n, true); return b; }
function u128le(n: bigint) {
const b = new Uint8Array(16), dv = new DataView(b.buffer);
dv.setBigUint64(0, n & 0xffffffffffffffffn, true);
dv.setBigUint64(8, n >> 64n, true);
return b;
}
const concat = (...a: Uint8Array[]) => { const o = new Uint8Array(a.reduce((s,x)=>s+x.length,0)); let i=0; for (const x of a){o.set(x,i);i+=x.length;} return o; };
// Transfer (tx_type = 1)
const bytes = concat(
DOMAIN,
Uint8Array.of(1), // tx_type
u64le(7n), // from_index
u64le(42n), // to_index
aliceIdBytes, // from_account_id (32)
bobIdBytes, // to_account_id (32)
u128le(1_000_000n), // amount
u64le(3n), // nonce
);
const signature = await sign(bytes, aliceSecret32); // 64-byte Ed25519 sig
Worked example: Trade
The Trade layout reuses the helpers above. It adds a 4-byte encoder for the two
u32 asset ids:
import { sign } from "@noble/ed25519";
// DOMAIN, u64le, u128le, concat are reused from the Transfer example above.
function u32le(n: number) { const b = new Uint8Array(4); new DataView(b.buffer).setUint32(0, n, true); return b; }
// Trade (tx_type = 4)
const bytes = concat(
DOMAIN,
Uint8Array.of(4), // tx_type
u64le(7n), // account_index
accountIdBytes, // account_id (32)
u32le(0), // from_asset (0 = SSD)
u32le(1), // to_asset (1 = BTC)
u128le(5_000_000n), // input_amount
u128le(64_006_442_500_000n), // oracle_price_fp (= quote price_fp)
u64le(1_737_000_000n), // oracle_timestamp
u64le(4n), // nonce
);
const signature = await sign(bytes, accountSecret32); // 64-byte Ed25519 sig
The nonce in the bytes is the account's current spend nonce. Read it with
Read a balance. A signature over a stale nonce is rejected.
Confirming transactions
Use this to learn when a transaction is final. Every accepted spend returns
{ "success": true, ... } and a tx_hash. That
means queued, not settled.
Poll the receipt until it reaches finalized. The receipt has the inclusion
proof and, once the batch is recorded on Solana, the Solana signature.
curl -s "$SIRIUS_OWNER/tx/<tx_hash>/receipt"
# status: pending -> included -> proved -> finalized (or dropped, with a reason)
# -> { "tx_hash": "0x...", "status": "finalized", "epoch_number": 128,
# "inclusion_proof": { ... }, "solana_tx_signature": "<sig>", ... }
Treat a balance as spendable once its funding transaction is finalized.
pending or a 404 means not yet. dropped means it
will never apply. Never move value on the submit response alone.