The SDK
@burnandclaim/sdk: the API from TypeScript, typed from its contract, with a loop that runs a whole cleanup.
@burnandclaim/sdk is Burn & Claim's API client for TypeScript. It runs in Node 22 or later, browsers and every bundler, its types come from the API's contract, and it has one dependency, openapi-fetch.
The SDK source is in the repository; npm publication awaits its initial package setup. The install command below applies after that first release. The public HTTP API reference is usable independently.
npm install @burnandclaim/sdkThe client
createClient makes a client for the production API. Every option is optional:
| Option | What it does |
|---|---|
apiKey | Your organization's API key, on your server only. Refused in a browser unless allowKeyInBrowser is set |
baseUrl | Another origin to call, such as your own server's route in front of the API (Calling from a browser) |
fetch | The fetch to use. The global one by default |
retries | Tries after the first, for a 429, 502, 503 or 504 or a request that never reached the API, waiting as Retry-After says. 2 by default |
Its methods cover a cleanup, and each answers the response's body:
| Method | Route |
|---|---|
fees() | GET /v1/fees |
scan(wallet) | GET /v1/wallets/{address}/assets |
quote(request) | POST /v1/transactions/quote |
prepareRound(request) | POST /v1/transactions/rounds |
stamp(roundId, indexes) | POST /v1/transactions/rounds/{roundId}/stamp |
submit(transactions) | POST /v1/transactions/submit |
transaction(signature) | GET /v1/transactions/{signature} |
api reaches every other public route, typed from the API's contract. It answers { data, error } and never throws:
const { data, error } = await bnc.api.GET('/v1/stats')
if (error) console.error(error.code)
return dataA whole cleanup
reclaim(client, request) runs a cleanup from the selection to every transaction landing, as How a cleanup works describes: it prepares each round, stamps each approval just before the wallet signs it, submits the same signed bytes again while an answer is pending, stamps again what didn't land, and prepares again in a new round what was rejected or deferred. Your signTransactions signs and never sends. Reclaim SOL shows it whole.
Errors
A failed request throws a BurnAndClaimError, with the API's problem document in problem and its code, status and requestId. Branch on code, never on the message:
try {
await bnc.quote({ wallet, items })
} catch (error) {
if (isProblem(error, 'validation_failed')) {
for (const field of error.problem?.errors ?? []) console.log(field.pointer, field.detail)
} else if (isProblem(error, 'rate_limited')) {
console.log(`Try again in ${error.problem?.retryAfter} seconds`)
} else if (error instanceof BurnAndClaimError) {
console.error(error.status, error.code, error.requestId)
} else {
throw error
}
}Versions
The SDK follows SemVer, on 0.x until the partner API is frozen at 1.0.0. Each version is in its changelog.