SDK
Overview
The @shain/sdk TypeScript package. A client, PDA helpers, session math and a typed error surface.
Install
git clone https://github.com/shain-labs/shain-engine
cd shain-engine/sdk
npm install
npm run buildThe SDK is not yet published to npm. Link it locally or import directly from sdk/src while the program is in pre-deployment.
Public surface
| Export | Kind | Purpose |
|---|---|---|
ShainClient | class | High-level client — fetch, build, send |
derivePdas | function | Config, treasury, session PDA bundle |
associatedTokenAddress | function | ATA derivation without the full spl-token import |
treasuryAta | function | Treasury ATA + PDA + bump in one call |
snapshotSession | function | Raw account → UI-ready snapshot |
formatRemaining | function | 24h 15m / 5m 03s / expired |
tagFromCallsite | function | Stable u64 tag from (module, fn) |
ShainSdkError | class | Typed error with normalized reason codes |
SHAIN_SEEDS | constant | The byte strings the program uses as PDA seeds |
DEFAULT_PROGRAM_ID | constant | Canonical devnet program id |
Quick example
import { Connection, Keypair, PublicKey, clusterApiUrl } from "@solana/web3.js";
import { ShainClient, formatRemaining } from "@shain/sdk";
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const wallet = Keypair.generate();
const client = new ShainClient({
connection,
programId: new PublicKey("2T1Qs7f2hiy1sUQBWC7226xhXvCees97UfeqReRrnE66"),
wallet,
});
const snapshot = await client.snapshotSession();
if (snapshot?.active) {
console.log(`session: ${formatRemaining(snapshot)}`);
}Dependencies
The SDK depends on @solana/web3.js, @coral-xyz/anchor, @solana/spl-token and bn.js. It does not bundle a wallet adapter — the client accepts any object with publicKey and the optional sign methods (so both Keypair and wallet-adapter instances work).
Next
- ShainClient — every method documented.
- Session helpers — snapshots, formatters and tag generation.
- Error handling — how to branch on typed reasons.