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
| Tool | Version | Why |
|---|---|---|
rustc | 1.89.0 (pinned via rust-toolchain.toml) | Builds the on-chain program |
solana-cli | 3.1.13 | Key management, RPC interaction |
anchor-cli | 1.0.0 | Orchestrates the build and IDL generation |
node | ≥ 20 LTS | Runs the SDK and integration scripts |
Clone and build
git clone https://github.com/shain-labs/shain-engine
cd shain-engine
anchor buildThe first build takes 5–10 minutes while the Anchor and Solana crates cache. Subsequent builds are incremental.
Run the test suite
cargo test --package shain --test test_shainThe 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:
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:
cd sdk
npm install
npm run buildimport { 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
- Overview — conceptual map of the system.
- Engine / Instructions — every on-chain call documented.
- Integration / Gate a swap — bundle a Shain session with a downstream DEX call.