ShainShain/docs
Shain/Docs/Overview
SDK

Overview

The @shain/sdk TypeScript package. A client, PDA helpers, session math and a typed error surface.

Install

terminalbash
git clone https://github.com/shain-labs/shain-engine
cd shain-engine/sdk
npm install
npm run build

The 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

ExportKindPurpose
ShainClientclassHigh-level client — fetch, build, send
derivePdasfunctionConfig, treasury, session PDA bundle
associatedTokenAddressfunctionATA derivation without the full spl-token import
treasuryAtafunctionTreasury ATA + PDA + bump in one call
snapshotSessionfunctionRaw account → UI-ready snapshot
formatRemainingfunction24h 15m / 5m 03s / expired
tagFromCallsitefunctionStable u64 tag from (module, fn)
ShainSdkErrorclassTyped error with normalized reason codes
SHAIN_SEEDSconstantThe byte strings the program uses as PDA seeds
DEFAULT_PROGRAM_IDconstantCanonical devnet program id

Quick example

quick.tstypescript
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