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 directory | Source files |
|---|---|
solana | 222 |
tools | 24 |
src | 16 |
multiplayer | 14 |
tests | 12 |
scripts | 7 |
legacy | 2 |
assets | 1 |
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.
solana/oxark/programs/oxark/src/instructions/activate_season.rs L13–36 @ 77ad227 · MIT · originalpub 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(())- 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. - 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. - Line 18
pub admin: Signer<'info>,: Requires this account to have signed the transaction. - Line 23
require!(world.game_status == 0, ErrorCode::SeasonWrongStatus);: An explicit validation that aborts the instruction with an error. - Line 25
let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 32
msg!(: Logs to the program log, which is visible in explorers and the test output.
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 {- 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. - 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. - Line 50
ctx.accounts.game_world.require_collection_open(Clock::get()?.unix_timestamp)?;: Reads on-chain time from the Clock sysvar. - Line 51
require!(ctx.accounts.buyer_state.deposit_amount > 0, ErrorCode::NotRegistered);: An explicit validation that aborts the instruction with an error. - Line 58
CpiContext::new(: Makes a cross-program invocation into another program.
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;- Line 25
init,: Creates and pays for a new account. Space and payer must be specified. - 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. - Line 29
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 40
ctx.accounts.game_world.require_collection_open(Clock::get()?.unix_timestamp)?;: Reads on-chain time from the Clock sysvar. - Line 41
require!(ctx.accounts.seller_state.deposit_amount > 0, ErrorCode::NotRegistered);: An explicit validation that aborts the instruction with an error.
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;- Line 13
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - 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. - Line 17
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 22
pub player: Signer<'info>,: Requires this account to have signed the transaction. - 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.
| Directory | Command | Runs |
|---|---|---|
multiplayer | npm run start | node server.js |
solana/oxark | npm run lint | prettier */*.js "*/**/*{.js,.ts}" --check |
solana/client | npm run dev | vite |
solana/client | npm run test | node --test test/*.test.js |
circuits/hand_commitment | npm run test | echo "Error: no test specified" && exit 1 |
tools/ai-agent | npm run start | node agent.js |
tools/ai-agent | npm run test | node tests/t44-agent-e2e.js |
solana/oxark | anchor build | compile programs and generate IDLs |
solana/oxark | anchor test | local validator + test suite |
solana/oxark | anchor run test | cargo test |
What you could build from it
- Fork the SuperStack copy and extend it within the AI & Agents gaps listed on the idea page.
- Learn the pattern first: AI agents on Solana
- Learn the pattern first: Building and sending transactions from a client