TypeScript SDK
@skia-money/sdk is the hardened TypeScript client for the Skia settlement
API — commit/reveal swaps, edge-layer payments, portfolio/tier reads, and an
MCP (JSON-RPC 2.0) client. It is built against the live server contracts,
not a spec guess: where the incoming skeleton and the server disagreed, the
server won, and every hardening decision is recorded.
This page is the overview. The full package-level reference — configuration,
authentication, the error taxonomy, advanced usage, and migration guides —
lives at the SDK docs site sdk.skia.money
(Docusaurus).
Install
The package is not published to npm yet; consume it from the monorepo (bun resolves TS directly):One-shot sovereign swap
senderWallet). Pass bearerToken in the config to pin it.
Chain keys and settlement ids
The wire accepts twelve app-chain keys — eight live (each backed by a canonical testnet deployment) and four dormant (taiko, bsc, polygon, hyperevm; hyperevm staged). Dormant keys carry
status: "dormant" everywhere and are refused client-side by the SDK.
SDK drift note: the SDK as of v0.2.1 carries ten keys (seven live + three
dormant) and does not yet know
monad or hyperevm. The catch-up toward the
twelve-key wire is tracked in the drift ledger
(docs/ops/sdk-hardening-drift.md). The wire truth above is what the server
answers today.SKIA_CHAINS[key].chainIdNumericis the production id the label derives from — do NOT build signature domains or explorer links from it.- The real settlement ids live in
SKIA_CHAINS[key].settlementChainIdNumericand, authoritatively, inWalletSummary.settlementNetwork.chainIdNumeric.
Simulated settlements — txHash is nullable, always labeled
A swap can succeed without touching a chain (DB-simulated settlement on non-backed lanes). Every reveal response is normalized by the SDK:Reliability semantics
- Idempotency:
swap()andcommit()accept anidempotencyKey, cached in a pluggable store (MemoryIdempotencyStoreby default — inject your own for persistence across restarts). - Single-fire:
reveal()never transport-retries (an already-revealed commit throws).commit()is single-fire by default too — the server ignores theIdempotency-Keyheader today (CONTRACT-1), so an automatic mid-timeout retry could double-commit. Opt in withretryMutatingRequests: trueif you accept that trade. - Crash recovery: died between commit and reveal —
resumeSwap({ commit })reveals once and recovers from order history on ALREADY_REVEALED; died right after reveal — the next call recovers the txHash fromGET /api/wallets/{address}/orders, matched by window + token hints and markedrecovered: true. Zero or multiple candidates refuse to guess — money is never matched ambiguously. - Retries: exponential backoff with full jitter (base 500ms, cap 8s,
3 retries), honoring
Retry-After. Transport errors and 429/5xx retry — including 5xx with no JSON body. Protocol errors (402, hash mismatch, single-fire semantics) never do.
Edge payments with a guard
Skia’s edge lane is a custom pay-and-resubmit protocol, honestly named not x402: a 402 carries aX-Payment-Request header (base64 JSON), the payment
settles out of band via POST /api/payment/verify, and the identical quote
request is resubmitted. Auto-pay is capped or refused — enabling
autoPayX402 without a paymentGuard throws at construction time:
PaymentGuardViolationError with the reason and paymentId.
MCP client
Error taxonomy at a glance
SkiaApiError (status + server code + retryable + details) with
specializations: RateLimitError, PaymentRequiredError, AlreadyRevealedError,
CommitExpiredError, OrderSenderMismatchError, SkiaNetworkError,
PaymentGuardViolationError, McpRpcError/McpProtocolError, and
client-side fail-fast InvalidParamError. Server codes map 1:1
(COMMITMENT_HASH_MISMATCH, QUOTE_EXPIRED, SIGNER_MISMATCH, …). A 2xx
with a non-JSON body raises MALFORMED_RESPONSE — never a null that crashes
downstream. The full table with retry rules is at
sdk.skia.money.
Posture (read before quoting custody or auth)
WalletSummary.custodyis one ofserver-custodial | simulated | external; server-custodial is the only production path in Phase 1.- The bearer is an UNSIGNED address (simulated ethSigAuth) — fine for testnet due diligence, a mainnet blocker. Auth stays pluggable; nothing in the SDK stores or transmits key material — signers are injected.
Where to next
- Full package reference: sdk.skia.money.
- Wire truth and the generated endpoint pages: API Reference.
- Drive the same flows from an LLM agent: MCP Server.