Full lesson
cypherpunk-hackathon2025
A decentralized prediction market platform on Solana empowering users to forecast real-world events. Focused on transparency & accountability.
What it does
From the project README:
[](https://cypherpunk-hackathon2025-three.vercel.app/) [](https://solana.com) [](https://nextjs.org) [](https://www.typescriptlang.org/)
- Original
- Edgadafi/cypherpunk-hackathon2025
- SuperStack fork
- Blockchains/cypherpunk-hackathon2025 @
495cde8 - Stars
- 1
- Last push (original)
- 2025-11-14
- Languages
- TypeScript, Rust, Shell, JavaScript, HTML, PowerShell
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- DeFi
- Licence
- MIT
- Homepage
- https://cypherpunk-hackathon2025-three.vercel.app
Architecture
129 source files. By extension: .tsx ×69, .ts ×42, .js ×13, .rs ×5.
| Top-level directory | Source files |
|---|---|
prediction-market | 74 |
archive | 27 |
prediction-market-latam | 12 |
config | 11 |
playground-versions | 4 |
(root) | 1 |
On-chain programs: prediction-market-latam/programs/prediction-market
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/cypherpunk-hackathon2025/. 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.
playground-versions/PRISMAFI_SOLANA_PLAYGROUND_FINAL.rs L205–228 @ 495cde8 · MIT · originalpub struct CreateMarket<'info> { #[account( init, payer = authority, space = 8 + Market::INIT_SPACE, seeds = [b"market", authority.key().as_ref(), &Sha256::digest(question.as_bytes())[..]], bump )] pub market: Account<'info, Market>, #[account(mut)] pub authority: Signer<'info>, pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct PlaceBet<'info> { #[account(mut)] pub market: Account<'info, Market>, #[account( init_if_needed, payer = user,- Line 207
init,: Creates and pays for a new account. Space and payer must be specified. - Line 210
seeds = [b"market", authority.key().as_ref(), &Sha256::digest(question.as_bytes())[..]],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 211
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 216
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 227
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
playground-versions/PRISMAFI_SOLANA_PLAYGROUND.rs L205–228 @ 495cde8 · MIT · original #[account( init, payer = authority, space = 8 + Market::INIT_SPACE, seeds = [b"market", authority.key().as_ref(), question.as_bytes()], bump )] pub market: Account<'info, Market>, #[account(mut)] pub authority: Signer<'info>, pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct PlaceBet<'info> { #[account(mut)] pub market: Account<'info, Market>, #[account( init_if_needed, payer = user, space = 8 + UserPosition::INIT_SPACE,- Line 206
init,: Creates and pays for a new account. Space and payer must be specified. - Line 209
seeds = [b"market", authority.key().as_ref(), question.as_bytes()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 210
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 215
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 226
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
playground-versions/PRISMAFI_SIMPLE_PLAYGROUND.rs L37–60 @ 495cde8 · MIT · original pub fn place_bet( ctx: Context<PlaceBet>, outcome: bool, amount: u64, ) -> Result<()> { require!(amount > 0, PredictionMarketError::InvalidAmount); let market = &mut ctx.accounts.market; require!(!market.resolved, PredictionMarketError::MarketResolved); require!( Clock::get()?.unix_timestamp < market.end_time, PredictionMarketError::MarketExpired ); let position = &mut ctx.accounts.position; position.user = ctx.accounts.user.key(); position.market = market.key(); position.outcome = outcome; position.amount = position.amount.checked_add(amount).unwrap(); position.claimed = false; position.bump = ctx.bumps.position; if outcome { market.total_yes_amount = market.total_yes_amount.checked_add(amount).unwrap();- Line 42
require!(amount > 0, PredictionMarketError::InvalidAmount);: An explicit validation that aborts the instruction with an error. - Line 47
Clock::get()?.unix_timestamp < market.end_time,: Reads on-chain time from the Clock sysvar. - Line 55
position.amount = position.amount.checked_add(amount).unwrap();: Uses checked arithmetic so overflow fails instead of wrapping. - Line 57
position.bump = ctx.bumps.position;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
playground-versions/PRISMAFI_MINIMAL.rs L37–60 @ 495cde8 · MIT · original // Transfer SOL let cpi_ctx = CpiContext::new( ctx.accounts.system_program.to_account_info(), anchor_lang::system_program::Transfer { from: ctx.accounts.user.to_account_info(), to: ctx.accounts.vault.to_account_info(), }, ); anchor_lang::system_program::transfer(cpi_ctx, amount)?; Ok(()) }} #[derive(Accounts)]pub struct CreateMarket<'info> { #[account( init, payer = authority, space = 8 + 32 + 100 + 8 + 8 + 8 + 1, seeds = [b"market", authority.key().as_ref()], bump )] pub market: Account<'info, Market>,- Line 39
let cpi_ctx = CpiContext::new(: Makes a cross-program invocation into another program. - Line 54
init,: Creates and pays for a new account. Space and payer must be specified. - Line 57
seeds = [b"market", authority.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 58
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
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 | next dev |
. | npm run start | next start |
. | npm run build | next build |
. | npm run lint | next lint |
prediction-market-latam | npm run dev | next dev |
prediction-market-latam | npm run start | next start |
prediction-market-latam | npm run build | next build |
prediction-market-latam | npm run test | vitest |
prediction-market-latam | npm run lint | next lint |
prediction-market | npm run dev | next dev |
prediction-market | npm run start | next start |
prediction-market | npm run build | next build |
prediction-market | npm run test | echo 'No tests configured yet' && exit 0 |
prediction-market | npm run lint | eslint |
prediction-market-latam | anchor build | compile programs and generate IDLs |
prediction-market-latam | anchor test | local validator + test suite |
What you could build from it
- Fork the SuperStack copy and extend it within the DeFi gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)
- Learn the pattern first: SPL Tokens: mints, accounts and transfers