Skip to content
SDK

TypeScript SDK

Strongly typed primitives over the kernel. Subscribe to verified state, attest claims, settle capital, and observe flows — every event narrows its own payload.

Install

bash
pnpm add @axk/sdk

Kernel

kernel.ts
ts
import { Kernel } from '@axk/sdk'
const kernel = new Kernel({
network: 'mainnet',
role: 'liquidity',
attest: process.env.AXK_ATTESTATION_KEY,
})
await kernel.connect() // returns a connected handle
await kernel.disconnect() // graceful shutdown

Events

subscribe.ts
ts
// typed subscription — payload narrows by schema
kernel.on('STATE_VERIFIED', (event) => {
if (event.schema === 'trade.delivery.v1') {
// event.payload is now TradeDeliveryV1
}
if (event.schema === 'carbon.retire.v2') {
// event.payload is now CarbonRetireV2
}
})
// or filter on subscription
kernel.subscribe({
schema: ['trade.delivery.v1', 'settle.payout.v1'],
region: ['rw', 'ug', 'ke'],
})

Settle

Liquidity-role nodes can atomically settle in the same block the event was verified. Returns a transaction handle with the XRPL id, elapsed time, and proof hash.

settle.ts
ts
const tx = await kernel.settle({
tx: event.proof.hash,
verifier: event.attest.id,
amount: event.payload.usd,
currency: 'USDC',
recipient: 'rUv3...',
})
// tx.id — XRPL transaction id (publicly verifiable)
// tx.elapsed — wall-clock ms from call to finality
// tx.proof.hash — kernel proof hash (same family as event.proof.hash)

Attest

Originator + Vector roles can attest new claims. The kernel handles signature, verifier delegation, and broadcast — you provide the payload.

attest.ts
ts
await kernel.attest({
schema: 'trade.delivery.v1',
payload: { id: 'RW-004421', cooperative: 'Nyamasheke', kg: 2400 },
verifier: { id: 'RISA·trade', standard: 'ISO/IEC 17025' },
})

Types & schemas

Every kernel primitive is generic over the schema union. Schemas are versioned (v1, v2) and additive — never breaking — so SDK upgrades are safe.

types.ts
ts
import type {
Kernel,
KernelEvent,
TradeDeliveryV1,
CarbonRetireV2,
SettlePayoutV1,
InsureClaimV1,
} from '@axk/sdk'
// strict union — payload is always narrowed by schema
type Handler = (e: KernelEvent) => void