ShainShain/docs
Shain/Docs/Quick start
Getting started

Quick start

The shortest path from clone to a live session on devnet. Ten minutes if you already have Rust and the Solana toolchain installed.

Prerequisites

ToolVersionWhy
rustc1.89.0 (pinned via rust-toolchain.toml)Builds the on-chain program
solana-cli3.1.13Key management, RPC interaction
anchor-cli1.0.0Orchestrates the build and IDL generation
node≥ 20 LTSRuns the SDK and integration scripts

Clone and build

terminalbash
git clone https://github.com/shain-labs/shain-engine
cd shain-engine
anchor build

The first build takes 5–10 minutes while the Anchor and Solana crates cache. Subsequent builds are incremental.

Run the test suite

terminalbash
cargo test --package shain --test test_shain

The test suite runs against litesvm — no validator, no network. Nine scenarios cover the happy path and the main failure modes (expired session, insufficient holding, double-open, rent refund on cleanup).

Expected output:

outputtext
running 9 tests
test initialize_sets_config ... ok
test start_session_happy_path ... ok
test start_session_fails_when_holding_below_min ... ok
test start_session_fails_when_already_active ... ok
test gated_action_increments_counter_while_active ... ok
test gated_action_fails_after_expiry ... ok
test close_session_fails_while_active ... ok
test close_session_after_expiry_refunds_rent ... ok
test restart_after_expiry_succeeds_and_counts ... ok

test result: ok. 9 passed; 0 failed.

Open a session (SDK)

The simplest way to open a session from your own code is the TypeScript SDK. From a fresh repo:

terminalbash
cd sdk
npm install
npm run build
examples/basic_session.tstypescript
import { Connection, Keypair, PublicKey, clusterApiUrl } from "@solana/web3.js";
import { ShainClient } 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 shainMint = new PublicKey(process.env.SHAIN_MINT!);
const userAta = client.ata(wallet.publicKey, shainMint);

const session = await client.startSession({
  shackleMint: shainMint,
  userTokenAccount: userAta,
});
// { signature, sessionPda, startedAt, expiresAt }

Next steps