Getting Started
Install @trustless-work/escrow-js and create a TrustlessWorkClient.
Overview
The Trustless Work JavaScript SDK is a typed, framework-agnostic client over Core API v2. It uses native fetch (Node 18+ / browsers) — no Axios, no React peers.
Quick links
Setup
Create a client (recommended)
import { TrustlessWorkClient, development } from "@trustless-work/escrow-js";
const client = new TrustlessWorkClient({
baseURL: development,
apiKey: process.env.API_KEY,
});
await client.rest.listEscrows({ scope: "mine", limit: 20 });
await client.graphql.getEscrow({ contractId: "C..." });This is the preferred pattern for NestJS / Angular DI and server apps.
Or configure a default client
Vanilla equivalent of React’s TrustlessWorkConfig:
import {
configureTrustlessWork,
escrowRest,
escrowGraphql,
development,
} from "@trustless-work/escrow-js";
configureTrustlessWork({
baseURL: development,
apiKey: process.env.API_KEY,
getAccessToken: async () => sessionToken,
defaultHeaders: { "X-TW-Platform": platformId },
});
await escrowRest().listEscrows({ scope: "mine", limit: 20 });
await escrowGraphql().getEscrow({ contractId: "C..." });Build → sign → send
Typical operate flow:
Call a REST method to get an unsigned XDR (and for deploy, a predicted
contractId).Sign the XDR with the correct role wallet.
Submit with
sendTransaction.
For reads, call REST or GraphQL methods directly — they return Promises (pair with your own cache if needed).
Client options
baseURL
Core API host (development / mainNet, or any URL string)
apiKey
x-api-key header
getAccessToken
Optional Bearer getter — sync or Promise (re-read per request)
defaultHeaders
Merged into every request (e.g. X-TW-Platform)
fetch
Optional custom fetch (tests, polyfills, undici)
timeoutMs
Optional timeout via AbortSignal.timeout
Next steps
Architecture — entry points and layers
Operate — mutate methods
REST Reads —
GET /escrows*Runtimes — Node, NestJS, Angular, browser
Errors — Problem Details helpers
Supports single-release and multi-release. Use the matching payload type and EscrowType for each flow.
Last updated