Versioned builds live under /sdk/<version>/. Current: 0.3.3. Latest alias: latest
Quick embed (SRI pinned):
<script src="https://cdn.blazedefi.com/sdk/0.3.3/js/index.js"
integrity="sha256-9F4XbjSBgRo3RaNWFJd/g96U4iv5n0GFJj/JgFaUveQ="
crossorigin="anonymous"></script>
<script>
(async () => {
const bc = await BlazeConnect.ready({ timeoutMs: 3000 });
if (!bc.isInstalled) return;
bc.on('accountChanged', ({ publicKey }) => console.log('accountChanged', publicKey));
const { publicKey } = await bc.connect();
console.log(publicKey);
})();
</script>
ESM (SDK v0.2.0+):
<script type="module">
import { BlazeClient } from 'https://cdn.blazedefi.com/sdk/0.3.3/js/index.js';
const client = new BlazeClient({ baseUrl: 'https://connect.blazedefi.com' });
console.log(await client.getHealth());
</script>
Live demo
Try the demo page using the latest SDK build, then check the docs:
Getting started
TypeScript (Node/Vite):
// install
npm install blaze-sdk
// usage
import { BlazeClient } from 'blaze-sdk';
const client = new BlazeClient({ baseUrl: 'https://connect.blazedefi.com' });
console.log(await client.getHealth());
Plain JS via CDN (ESM):
<script type="module">
import { BlazeClient } from 'https://cdn.blazedefi.com/sdk/latest/js/index.js';
const client = new BlazeClient({ baseUrl: 'https://connect.blazedefi.com' });
console.log(await client.getLatestBlock());
</script>
Wallet provider (IIFE global): include once, then use BlazeConnect.
<script src="https://cdn.blazedefi.com/sdk/latest/wallet/blaze-connect.iife.js" crossorigin="anonymous"></script>
<script>
(async () => {
const bc = await BlazeConnect.ready({ timeoutMs: 3000 });
if (!bc.isInstalled) return;
const { publicKey } = await bc.connect();
console.log('pk', publicKey);
})();
</script>
Common tasks
List recent blocks with auto-pagination
const page = await client.listBlocks({ limit: 5 });
for await (const b of page.asIterable()) {
console.log(b.height, b.hash);
}
Estimate fees and submit
const instructions = [
{ type: 'transfer', from, to, amount: '100000000', data: { token_address } },
];
const est = await client.estimateFees(instructions);
// sign transaction outside SDK (ed25519 over sha3-256) then submit
const { hash } = await client.submitTransaction(signedTx);
await client.waitForConfirmed(hash, { minConfirmations: 1 });
Quote a swap
const q = await client.quoteSwap(poolAddr, blazeAddr, otherTokenAddr, '100000000');
console.log('min received', q.minimum_received);
Amount helpers
toBaseUnits('1.23', 8) // '123000000'
fromBaseUnits('123000000', 8) // '1.23'
Explore more in BlazeClient, toBaseUnits, makePager.
Essentials
- API base:
https://connect.blazedefi.com - Amounts: base units as strings (uint64); native token has 8 decimals
- Errors: non-2xx → JSON
{ error, message, details? }; HTTP status is authoritative - Environments: modern browsers (ESM) and Node ≥ 18 (global fetch)
Versioning & CDN cache
- Versioned paths are immutable:
/sdk/<version>/... - latest alias points to the most recent release and is short-cached
- SRI snippet above pins the exact file integrity for extra safety