@hashlock-tech/sdk
v0.4.0
Published
TypeScript SDK for the Hashlock Markets developer API — non-custodial cross-chain atomic swaps (BTC ↔ EVM/TRON) over sealed RFQ + HTLC.
Readme
@hashlock-tech/sdk
TypeScript SDK for the Hashlock Markets developer API —
non-custodial cross-chain atomic swaps (BTC ↔ EVM/TRON). Runs on Node 18+, browsers, and edge runtimes
(native fetch / WebSocket, zero runtime dependencies).
⚠️ Sandbox / testnet preview (0.x) — defaults to
api-dev.hashlock.markets, testnets only, pre-mainnet. The API may change before the stable1.0. Not for mainnet funds.
npm i @hashlock-tech/sdkimport { HashlockClient, newSecret, verifyWebhook, MakerFeed } from '@hashlock-tech/sdk';
const client = new HashlockClient({ apiKey: process.env.HASHLOCK_API_KEY! });
await client.me();
// cursor pagination — page or auto-iterate
const page = await client.listSwaps({ limit: 20 });
for await (const swap of client.swaps()) { /* … */ }
// webhooks: verify a delivery against the raw body
const ok = await verifyWebhook({ secret, rawBody, signature: req.headers['x-hashlock-signature'], timestamp: req.headers['x-hashlock-timestamp'] });
// maker feed: stream RFQs and quote over a socket
const feed = new MakerFeed({ apiKey, onRfq: (rfq) => feed.quote(rfq.id, '650000') });
await feed.connect();Settlement is custody-agnostic: buildFund / buildClaim / buildRefund return unsigned transactions —
sign with your wallet or HSM (see ../examples/fireblocks) and broadcast(...)
(or let your custody provider broadcast). See the root README for the full swap lifecycle.
Build
npm install && npm run build # tsup → dist (esm + d.ts)
npm run typecheckMIT
