Sol.College

Full lesson

0xark

On-chain TCG × ZK × x402 × AI agents on Solana

What it does

From the project README:

Every duel is settled on-chain. Every win is engraved onto the card that won it. Cards carry an immutable battle history — wins, KOs, and the chain of wallets that have owned them — and that history is what makes a card rare, not a number stamped on it at mint.
Original
r0ze998/0xark
SuperStack fork
Blockchains/0xark @ 77ad227
Stars
0
Last push (original)
2026-09-08
Languages
JavaScript, Rust, CSS, Python, HTML, Circom
Detected stack
Anchorweb3.js
Categories
AI & AgentsDeFi
Licence
MIT

Architecture

298 source files. By extension: .js ×201, .rs ×91, .py ×4, .tsx ×1, .ts ×1.

Top-level directorySource files
solana222
tools24
src16
multiplayer14
tests12
scripts7
legacy2
assets1

On-chain programs: solana/oxark/programs/oxark, solana/oxark/programs/oxark-cards

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/0xark/. 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.

r0ze998/0xark · solana/oxark/programs/oxark/src/instructions/activate_season.rs L13–36 @ 77ad227 · MIT · original
pub struct ActivateSeason<'info> {    #[account(mut, seeds = [GameWorld::SEED], bump = game_world.bump)]    pub game_world: Account<'info, GameWorld>,     #[account(constraint = admin.key() == ADMIN_PUBKEY @ ErrorCode::NotAdmin)]    pub admin: Signer<'info>,} pub fn handle_activate_season(ctx: Context<ActivateSeason>) -> Result<()> {    let world = &mut ctx.accounts.game_world;    require!(world.game_status == 0, ErrorCode::SeasonWrongStatus);     let now = Clock::get()?.unix_timestamp;    require!(        now >= world.waitlist_close_timestamp && now >= world.start_timestamp,        ErrorCode::WaitlistStillOpen    );     world.game_status = 1;    msg!(        "ActivateSeason: status 0->1 (active), participants={}",        world.total_participants    );    Ok(())
  1. Line 14 #[account(mut, seeds = [GameWorld::SEED], bump = game_world.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 14 #[account(mut, seeds = [GameWorld::SEED], bump = game_world.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 18 pub admin: Signer<'info>,: Requires this account to have signed the transaction.
  4. Line 23 require!(world.game_status == 0, ErrorCode::SeasonWrongStatus);: An explicit validation that aborts the instruction with an error.
  5. Line 25 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  6. Line 32 msg!(: Logs to the program log, which is visible in explorers and the test output.
r0ze998/0xark · solana/oxark/programs/oxark/src/instructions/accept_listing.rs L37–60 @ 77ad227 · MIT · original
    pub seller: AccountInfo<'info>,     pub system_program: Program<'info, System>,    #[account(seeds = [GameWorld::SEED], bump = game_world.bump)]    pub game_world: Account<'info, GameWorld>, } pub fn handle_accept_listing(    ctx: Context<AcceptListing>,    _seller_pubkey: Pubkey,    card_id: u8,) -> Result<()> {    ctx.accounts.game_world.require_collection_open(Clock::get()?.unix_timestamp)?;    require!(ctx.accounts.buyer_state.deposit_amount > 0, ErrorCode::NotRegistered);     let price = ctx.accounts.listing.price;    let seller = ctx.accounts.listing.seller;     // Transfer SOL: buyer → seller (0% fee, no platform cut)    transfer(        CpiContext::new(            ctx.accounts.system_program.key(),            Transfer {
  1. Line 40 #[account(seeds = [GameWorld::SEED], bump = game_world.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 40 #[account(seeds = [GameWorld::SEED], bump = game_world.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 50 ctx.accounts.game_world.require_collection_open(Clock::get()?.unix_timestamp)?;: Reads on-chain time from the Clock sysvar.
  4. Line 51 require!(ctx.accounts.buyer_state.deposit_amount > 0, ErrorCode::NotRegistered);: An explicit validation that aborts the instruction with an error.
  5. Line 58 CpiContext::new(: Makes a cross-program invocation into another program.
r0ze998/0xark · solana/oxark/programs/oxark/src/instructions/create_listing.rs L25–48 @ 77ad227 · MIT · original
        init,        payer = seller,        space = TradeListing::SIZE,        seeds = [b"trade", seller.key().as_ref(), &[card_id]],        bump,    )]    pub listing: Account<'info, TradeListing>,     pub system_program: Program<'info, System>,    #[account(seeds = [GameWorld::SEED], bump = game_world.bump)]    pub game_world: Account<'info, GameWorld>, } pub fn handle_create_listing(ctx: Context<CreateListing>, card_id: u8, price: u64) -> Result<()> {    ctx.accounts.game_world.require_collection_open(Clock::get()?.unix_timestamp)?;    require!(ctx.accounts.seller_state.deposit_amount > 0, ErrorCode::NotRegistered);     require!(price >= MIN_LISTING_PRICE, ErrorCode::PriceTooLow);     // Escrow: remove card from seller vault now    ctx.accounts.seller_state.remove_card(card_id)?;     let listing = &mut ctx.accounts.listing;
  1. Line 25 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 28 seeds = [b"trade", seller.key().as_ref(), &[card_id]],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 29 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 40 ctx.accounts.game_world.require_collection_open(Clock::get()?.unix_timestamp)?;: Reads on-chain time from the Clock sysvar.
  5. Line 41 require!(ctx.accounts.seller_state.deposit_amount > 0, ErrorCode::NotRegistered);: An explicit validation that aborts the instruction with an error.
r0ze998/0xark · solana/oxark/programs/oxark/src/instructions/set_title.rs L13–36 @ 77ad227 · MIT · original
        init_if_needed,        payer = player,        space = PlayerTitle::SIZE,        seeds = [b"player_title", player.key().as_ref()],        bump,    )]    pub player_title: Account<'info, PlayerTitle>,     #[account(mut)]    pub player: Signer<'info>,     pub system_program: Program<'info, System>,} pub fn handle_set_title(ctx: Context<SetTitle>, title_idx: u8) -> Result<()> {    require!(title_idx < TITLE_COUNT, ErrorCode::InvalidAction);     let pt = &mut ctx.accounts.player_title;    if pt.owner == Pubkey::default() {        // Init: always unlock title 0 (Traveler)        pt.owner = ctx.accounts.player.key();        pt.equipped = 0;        pt.unlocked = 0b0000_0001; // bit 0 = Traveler always on        pt.bump = ctx.bumps.player_title;
  1. Line 13 init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
  2. Line 16 seeds = [b"player_title", player.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 17 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 22 pub player: Signer<'info>,: Requires this account to have signed the transaction.
  5. Line 28 require!(title_idx < TITLE_COUNT, ErrorCode::InvalidAction);: 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
multiplayernpm run startnode server.js
solana/oxarknpm run lintprettier */*.js "*/**/*{.js,.ts}" --check
solana/clientnpm run devvite
solana/clientnpm run testnode --test test/*.test.js
circuits/hand_commitmentnpm run testecho "Error: no test specified" && exit 1
tools/ai-agentnpm run startnode agent.js
tools/ai-agentnpm run testnode tests/t44-agent-e2e.js
solana/oxarkanchor buildcompile programs and generate IDLs
solana/oxarkanchor testlocal validator + test suite
solana/oxarkanchor run testcargo test

What you could build from it

Used in lessons