Full lesson
BumpTrade
What it does
From the project README:
Real-time 3D bumper-car wager arena. **Solana devnet is the default chain**; Robinhood Chain testnet stays supported behind the same chain adapter. Every player stakes 100 free `BUMP` and starts with a balance. Every hit moves balance from the car you hit to you; drop to zero and you are liquidated. At the end, each player is paid `stake x final balance / start balance` from the pot in one transaction. Play is gasless: a player only signs a message, the server relayer pays the gas.
- Original
- Vamp-Labs/BumpTrade
- SuperStack fork
- Blockchains/BumpTrade @
a0722a5 - Stars
- 0
- Last push (original)
- 2026-10-11
- Languages
- TypeScript, Python, Solidity, JavaScript, Rust, CSS
- Detected stack
- @solana/kitAnchor
- Categories
- Other
- Licence
- MIT
Architecture
240 source files. By extension: .ts ×204, .rs ×16, .sol ×11, .py ×9.
| Top-level directory | Source files |
|---|---|
src | 90 |
packages | 60 |
server | 43 |
solana | 17 |
contracts | 14 |
tools | 10 |
indexer | 5 |
(root) | 1 |
On-chain programs: solana/programs/bump_arena
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/bumptrade/. 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/programs/bump_arena/src/instructions/open_match.rs L13–36 @ a0722a5 · MIT · original pub operator: Signer<'info>, #[account(seeds = [CONFIG_SEED], bump = config.bump)] pub config: Account<'info, Config>, #[account(address = config.mint)] pub mint: Account<'info, Mint>, #[account(init, payer = operator, space = 8 + Match::INIT_SPACE, seeds = [MATCH_SEED, match_id.as_ref()], bump)] pub match_account: Account<'info, Match>, #[account( init, payer = operator, seeds = [VAULT_SEED, match_id.as_ref()], bump, token::mint = mint, token::authority = match_account, )] pub vault: Account<'info, TokenAccount>, pub token_program: Program<'info, Token>, pub system_program: Program<'info, System>,} pub fn handler(ctx: Context<OpenMatch>, match_id: [u8; 32], max_players: u8, join_deadline: i64) -> Result<()> { let config = &ctx.accounts.config; require!(!config.paused, BumpError::Paused); let now = Clock::get()?.unix_timestamp;- Line 13
pub operator: Signer<'info>,: Requires this account to have signed the transaction. - Line 14
#[account(seeds = [CONFIG_SEED], bump = config.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 14
#[account(seeds = [CONFIG_SEED], bump = config.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 18
#[account(init, payer = operator, space = 8 + Match::INIT_SPACE, seeds = [MATCH_SEED, matc: Creates and pays for a new account. Space and payer must be specified. - Line 35
require!(!config.paused, BumpError::Paused);: An explicit validation that aborts the instruction with an error. - Line 36
let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
solana/programs/bump_arena/src/instructions/start_match.rs L1–24 @ a0722a5 · MIT · originaluse anchor_lang::prelude::*; use crate::constants::*;use crate::error::BumpError;use crate::events::MatchStarted;use crate::state::{Config, Match}; #[derive(Accounts)]#[instruction(match_id: [u8; 32])]pub struct StartMatch<'info> { #[account(constraint = operator.key() == config.operator @ BumpError::Unauthorized)] pub operator: Signer<'info>, #[account(seeds = [CONFIG_SEED], bump = config.bump)] pub config: Account<'info, Config>, #[account(mut, seeds = [MATCH_SEED, match_id.as_ref()], bump = match_account.bump)] pub match_account: Account<'info, Match>,} pub fn handler(ctx: Context<StartMatch>, match_id: [u8; 32]) -> Result<()> { let m = &mut ctx.accounts.match_account; require!(m.status == STATUS_OPEN, BumpError::BadStatus); require!(m.player_count >= 2, BumpError::NotEnoughPlayers); m.status = STATUS_STARTED; emit!(MatchStarted { match_id, settle_deadline: m.settle_deadline });- Line 12
pub operator: Signer<'info>,: Requires this account to have signed the transaction. - Line 13
#[account(seeds = [CONFIG_SEED], bump = config.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 13
#[account(seeds = [CONFIG_SEED], bump = config.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 21
require!(m.status == STATUS_OPEN, BumpError::BadStatus);: An explicit validation that aborts the instruction with an error. - Line 24
emit!(MatchStarted { match_id, settle_deadline: m.settle_deadline });: Emits an Anchor event that clients can parse from the logs.
solana/programs/bump_arena/src/instructions/join_match.rs L25–48 @ a0722a5 · MIT · original require!(!ctx.accounts.config.paused, BumpError::Paused); let now = Clock::get()?.unix_timestamp; let player = ctx.accounts.player.key(); let m = &mut ctx.accounts.match_account; require!(m.status == STATUS_OPEN, BumpError::MatchNotOpen); require!(now <= m.join_deadline, BumpError::JoinClosed); require!(m.player_count < m.max_players, BumpError::MatchFull); require!(m.seat_of(&player).is_none(), BumpError::AlreadyJoined); require!(vehicle_id < VEHICLE_COUNT, BumpError::BadVehicle); let seat = m.player_count as usize; m.players[seat] = player; m.session_keys[seat] = session_key; m.vehicles[seat] = vehicle_id; m.player_count += 1; let stake = m.stake; token::transfer( CpiContext::new( ctx.accounts.token_program.key(), Transfer { from: ctx.accounts.player_token.to_account_info(), to: ctx.accounts.vault.to_account_info(), authority: ctx.accounts.player.to_account_info(),- Line 25
require!(!ctx.accounts.config.paused, BumpError::Paused);: An explicit validation that aborts the instruction with an error. - Line 26
let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 40
let stake = m.stake;: Touches staking state: the amount locked and when it was locked. - Line 42
token::transfer(: An SPL token transfer through the Token Program. - Line 43
CpiContext::new(: Makes a cross-program invocation into another program.
solana/programs/bump_arena/src/instructions.rs L37–56 @ a0722a5 · MIT · original let bump = [match_bump]; let seeds: &[&[u8]] = &[MATCH_SEED, match_id.as_ref(), &bump]; token::transfer( CpiContext::new_with_signer( Token::id(), Transfer { from: vault, to: destination, authority: match_account }, &[seeds], ), amount, )} pub fn seat_token_account(info: &AccountInfo, owner: &Pubkey, mint: &Pubkey) -> Result<()> { require!(info.is_writable && info.owner == &Token::id(), BumpError::BadRemainingAccounts); let data = info.try_borrow_data()?; let account = TokenAccount::try_deserialize(&mut &data[..]).map_err(|_| error!(BumpError::BadRemainingAccounts))?; require_keys_eq!(account.owner, *owner, BumpError::BadRemainingAccounts); require_keys_eq!(account.mint, *mint, BumpError::BadRemainingAccounts); Ok(())}- Line 37
let bump = [match_bump];: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 39
token::transfer(: An SPL token transfer through the Token Program. - Line 40
CpiContext::new_with_signer(: Makes a CPI signed by a PDA. The signer seeds prove the program controls that address. - Line 50
require!(info.is_writable && info.owner == &Token::id(), BumpError::BadRemainingAccounts);: 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 | vite |
. | npm run build | tsc && vite build |
. | npm run lint | biome check src packages server indexer |
packages/shared | npm run test | vitest run --passWithNoTests |
packages/sol-client | npm run test | vitest run --passWithNoTests |
indexer | npm run dev | ponder dev |
indexer | npm run start | ponder start |
server | npm run dev | tsx watch src/index.ts |
server | npm run start | tsx src/index.ts |
server | npm run test | vitest run --passWithNoTests |
solana | npm run build | flock /tmp/bump-build.lock env PATH=$HOME/.cargo/bin:$PATH anchor build |
contracts | npm run build | forge build && node script/export-abi.mjs |
contracts | npm run test | forge test |
solana | anchor build | compile programs and generate IDLs |
solana | anchor test | local validator + test suite |
solana | anchor run test | cargo test -p bump_arena |
What you could build from it
- Fork the SuperStack copy and extend it within the Other gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)