Sol.College

Full lesson

ChainGo

ChainGo is a trust-minimized Gomoku game where the game account lives on Solana and active gameplay runs on MagicBlock Ephemeral Rollups for low-latency moves.

What it does

From the project README:

ChainGo is a trust-minimized Gomoku game where the game account lives on Solana and active gameplay runs on MagicBlock Ephemeral Rollups for low-latency moves.
Original
kick-pixel/ChainGo
SuperStack fork
Blockchains/ChainGo @ 8857913
Stars
0
Last push (original)
2026-05-07
Languages
TypeScript, CSS, Rust, Shell, HTML
Detected stack
AnchorNext.jsweb3.js
Categories
Gaming
Licence
MIT

Architecture

17 source files. By extension: .ts ×10, .tsx ×6, .rs ×1.

Top-level directorySource files
app10
actions6
programs1

On-chain programs: programs/chain_go

Dapp: devnet deploy pending

⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/chaingo/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

kick-pixel/ChainGo · programs/chain_go/src/lib.rs L337–360 @ 8857913 · MIT · original
// Account 上下文// ───────────────────────────────────────────── #[derive(Accounts)]#[instruction(game_id: u64)]pub struct CreateGame<'info> {    #[account(mut)]    pub player1: Signer<'info>,     #[account(        init_if_needed,        payer = player1,        space = GameState::LEN,        seeds = [b"game", player1.key().as_ref(), game_id.to_le_bytes().as_ref()],        bump,    )]    pub game: Account<'info, GameState>,     pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct JoinGame<'info> {    pub player2: Signer<'info>,
  1. Line 344 pub player1: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 347 init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
  3. Line 350 seeds = [b"game", player1.key().as_ref(), game_id.to_le_bytes().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  4. Line 351 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
kick-pixel/ChainGo · app/src/utils/program.ts L253–275 @ 8857913 · MIT · original
  boardP2: number[]  currentTurn: number  status: number  moveCount: number  bump: number} // ─────────────────────────────────────────────// PDA// ───────────────────────────────────────────── /** * 计算游戏账户 PDA�? * seeds = ["game", player1.pubkey] * FIX: 同步版本避免 await 地方混用 async/sync */export function getGamePda(player1: PublicKey, gameId: number | BN): [PublicKey, number] {  const id = BN.isBN(gameId) ? gameId : new BN(gameId)  const gameIdSeed = id.toArrayLike(Buffer, 'le', 8)  return PublicKey.findProgramAddressSync(    [Buffer.from('game'), player1.toBuffer(), gameIdSeed],    PROGRAM_ID  )}
  1. Line 257 bump: number: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  2. Line 265 * 计算游戏账户 PDA�? * seeds = ["game", player1.pubkey]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 271 return PublicKey.findProgramAddressSync(: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
appnpm run devvite
appnpm run buildtsc && vite build
actionsnpm run devnext dev
actionsnpm run startnext start
actionsnpm run buildnext build
actionsnpm run lintnext lint
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it

Used in lessons