Sol.College

Full lesson

JinAI

JinAI is a real-time multiplayer quiz game powered by Next.js, WebSockets, and Solana program. Players connect their Solana wallet, join quiz lobbies, compete in live quizzes, and earn on-chain rewards based on performance.

What it does

From the project README:

JinAI is a **real-time multiplayer quiz game** powered by **Next.js**, **WebSockets**, and **Solana on-chain logic**. Players connect their **Solana wallet**, join quiz lobbies, compete in live quizzes, and earn on-chain rewards based on performance.
Original
AtoMicKraK1n/JinAI
SuperStack fork
Blockchains/JinAI @ 040ac2a
Stars
1
Last push (original)
2025-12-19
Languages
TypeScript, Rust, JavaScript, CSS
Detected stack
AnchorNext.jsweb3.js
Categories
GamingConsumer & Social
Licence
MIT
Homepage
https://jinai.xyz

Architecture

142 source files. By extension: .tsx ×91, .ts ×28, .rs ×15, .js ×8.

Top-level directorySource files
src115
anchor19
postman4
(root)3
server1

On-chain programs: anchor/programs/jinai-here

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/jinai/. 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.

AtoMicKraK1n/JinAI · anchor/programs/jinai-here/src/instructions/appoint_pool.rs L1–24 @ 040ac2a · MIT · original
use anchor_lang::prelude::*;use crate::state::*; #[derive(Accounts)]pub struct AppointPool<'info> {    #[account(        init,        payer = authority,        space = 8 + GlobalState::INIT_SPACE,        seeds = [b"global-state"],        bump    )]    pub global_state: Account<'info, GlobalState>,        #[account(mut)]    pub authority: Signer<'info>,     /// CHECK: Explain why no checks are necessary for this field (e.g. "This account is only used for ... and does not require validation here")        pub treasury: AccountInfo<'info>,        pub system_program: Program<'info, System>,}     pub fn appoint_pool_handler(ctx: Context<AppointPool>, fee_basis_points: u16) -> Result<()> {
  1. Line 7 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 10 seeds = [b"global-state"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 11 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 16 pub authority: Signer<'info>,: Requires this account to have signed the transaction.
AtoMicKraK1n/JinAI · anchor/programs/jinai-here/src/instructions/join_pool.rs L13–36 @ 040ac2a · MIT · original
    )]    pub pool: Account<'info, Pool>,        #[account(        init,        payer = player_authority,        space = 8 + Player::INIT_SPACE,        seeds = [b"player", pool.pool_id.to_le_bytes().as_ref(), player_authority.key().as_ref()],        bump    )]    pub player: Account<'info, Player>,        #[account(mut)]    pub player_authority: Signer<'info>,        #[account(        mut,        seeds = [b"pool-vault", pool.pool_id.to_le_bytes().as_ref()],        bump    )]    pub pool_vault: SystemAccount<'info>,        pub system_program: Program<'info, System>,}
  1. Line 17 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 20 seeds = [b"player", pool.pool_id.to_le_bytes().as_ref(), player_authority.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 21 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 26 pub player_authority: Signer<'info>,: Requires this account to have signed the transaction.
AtoMicKraK1n/JinAI · anchor/programs/jinai-here/src/instructions/create_pool.rs L13–36 @ 040ac2a · MIT · original
    pub global_state: Account<'info, GlobalState>,     #[account(        init,        payer = creator,        space = Pool::INIT_SPACE,        seeds = [b"pool", global_state.pool_count.to_le_bytes().as_ref()],        bump    )]    pub pool: Account<'info, Pool>,     #[account(mut)]    pub creator: Signer<'info>,     pub system_program: Program<'info, System>,} pub fn create_pool_handler(    ctx: Context<CreatePool>,    min_deposit: u64,    end_time: i64,    prize_distribution: [u8; 4],) -> Result<()> {    let pool = &mut ctx.accounts.pool;
  1. Line 16 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 19 seeds = [b"pool", global_state.pool_count.to_le_bytes().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 20 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 25 pub creator: Signer<'info>,: Requires this account to have signed the transaction.
AtoMicKraK1n/JinAI · anchor/programs/jinai-here/src/instructions/secure_pool.rs L13–36 @ 040ac2a · MIT · original
     #[account(        seeds = [b"global-state"],        bump = global_state.bump    )]    pub global_state: Account<'info, GlobalState>,     #[account(mut)]    pub signer: Signer<'info>,}  pub fn secure_pool_handler(ctx: Context<SecurePool>) -> Result<()> {    let pool = &mut ctx.accounts.pool;     require!(pool.status == PoolStatus::InProgress, ErrorCode::InvalidPoolStatus);     require!(        ctx.accounts.signer.key() == pool.creator ||        ctx.accounts.signer.key() == ctx.accounts.global_state.authority,        ErrorCode::Unauthorized    );     pool.status = PoolStatus::InProgress;
  1. Line 15 seeds = [b"global-state"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 16 bump = global_state.bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 21 pub signer: Signer<'info>,: Requires this account to have signed the transaction.
  4. Line 28 require!(pool.status == PoolStatus::InProgress, ErrorCode::InvalidPoolStatus);: An explicit validation that aborts the instruction with an error.

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
.npm run devconcurrently "prisma generate" "next dev" "node server/index.js"
.npm run startnode server/index.js
.npm run buildprisma generate && prisma db push && next build
.npm run lintnext lint
anchornpm run testjest
anchornpm run lintprettier */*.js "*/**/*{.js,.ts}" --check
servernpm run startnode index.js
servernpm run testecho "Error: no test specified" && exit 1
anchoranchor buildcompile programs and generate IDLs
anchoranchor testlocal validator + test suite
anchoranchor run testnpm test

What you could build from it