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 directory | Source files |
|---|---|
app | 10 |
actions | 6 |
programs | 1 |
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.
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>,- Line 344
pub player1: Signer<'info>,: Requires this account to have signed the transaction. - Line 347
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - 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. - Line 351
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
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 )}- Line 257
bump: number: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - 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. - 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.
| Directory | Command | Runs |
|---|---|---|
app | npm run dev | vite |
app | npm run build | tsc && vite build |
actions | npm run dev | next dev |
actions | npm run start | next start |
actions | npm run build | next build |
actions | npm run lint | next lint |
. | anchor build | compile programs and generate IDLs |
. | anchor test | local validator + test suite |
. | anchor run test | yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts |
. | cargo build | Rust workspace build |
. | cargo test | Rust tests |
What you could build from it
- Fork the SuperStack copy and extend it within the Gaming gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Compressed NFTs and state compression
- Learn the pattern first: Building and sending transactions from a client