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 directory | Source files |
|---|---|
src | 115 |
anchor | 19 |
postman | 4 |
(root) | 3 |
server | 1 |
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.
anchor/programs/jinai-here/src/instructions/appoint_pool.rs L1–24 @ 040ac2a · MIT · originaluse 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<()> {- Line 7
init,: Creates and pays for a new account. Space and payer must be specified. - Line 10
seeds = [b"global-state"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 11
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 16
pub authority: Signer<'info>,: Requires this account to have signed the transaction.
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>,}- Line 17
init,: Creates and pays for a new account. Space and payer must be specified. - 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. - Line 21
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 26
pub player_authority: Signer<'info>,: Requires this account to have signed the transaction.
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;- Line 16
init,: Creates and pays for a new account. Space and payer must be specified. - 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. - Line 20
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 25
pub creator: Signer<'info>,: Requires this account to have signed the transaction.
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;- Line 15
seeds = [b"global-state"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 16
bump = global_state.bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 21
pub signer: Signer<'info>,: Requires this account to have signed the transaction. - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run dev | concurrently "prisma generate" "next dev" "node server/index.js" |
. | npm run start | node server/index.js |
. | npm run build | prisma generate && prisma db push && next build |
. | npm run lint | next lint |
anchor | npm run test | jest |
anchor | npm run lint | prettier */*.js "*/**/*{.js,.ts}" --check |
server | npm run start | node index.js |
server | npm run test | echo "Error: no test specified" && exit 1 |
anchor | anchor build | compile programs and generate IDLs |
anchor | anchor test | local validator + test suite |
anchor | anchor run test | npm test |
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