Full lesson
DoomsdayArk
Doomsday Ark
- Original
- ErenVance/DoomsdayArk
- SuperStack fork
- Blockchains/DoomsdayArk @
b62f1f4 - Stars
- 2
- Last push (original)
- 2025-07-18
- Languages
- Rust
- Detected stack
- Anchor
- Categories
- Other
- Licence
- MIT
- Homepage
- https://thedoomsdayark.com
Architecture
65 source files. By extension: .rs ×65.
| Top-level directory | Source files |
|---|---|
programs | 65 |
On-chain programs: programs/game
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/doomsdayark/. 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.
programs/game/src/instructions/manager/initialize_stake_token_pool.rs L25–48 @ b62f1f4 · MIT · original pub authority: Signer<'info>, /// The game account. #[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismatch)] pub game: Box<Account<'info, Game>>, /// The stake pool account to be created, managing staking operations and rewards. #[account( init, payer = authority, space = 8 + StakePool::INIT_SPACE, seeds = [STAKE_POOL_SEED], bump, )] pub stake_pool: Box<Account<'info, StakePool>>, /// The stake pool vault associated token account, holding staked tokens and accrued rewards. #[account( init_if_needed, payer = authority, associated_token::mint = token_mint, associated_token::authority = stake_pool )] pub stake_pool_token_vault: Box<Account<'info, TokenAccount>>,- Line 25
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 28
#[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismat: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 28
#[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismat: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 28
#[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismat: Checks that a stored pubkey field matches the passed account. - Line 31
/// The stake pool account to be created, managing staking operations and rewards.: Touches staking state: the amount locked and when it was locked. - Line 33
init,: Creates and pays for a new account. Space and payer must be specified. - Line 43
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
programs/game/src/instructions/manager/initialize_stake_voucher_pool.rs L25–48 @ b62f1f4 · MIT · original pub authority: Signer<'info>, /// The game account. #[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismatch)] pub game: Box<Account<'info, Game>>, /// The stake pool account to be created, managing staking operations and rewards. #[account( mut, seeds = [STAKE_POOL_SEED], bump, )] pub stake_pool: Box<Account<'info, StakePool>>, /// The stake pool voucher vault associated token account, holding staked tokens and accrued rewards. #[account( init, payer = authority, associated_token::mint = voucher_mint, associated_token::authority = stake_pool )] pub stake_pool_voucher_vault: Box<Account<'info, TokenAccount>>, /// The authority's associated token account from which tokens will be deposited.- Line 25
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 28
#[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismat: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 28
#[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismat: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 28
#[account(mut, seeds = [GAME_SEED], bump, has_one = authority @ ErrorCode::AuthorityMismat: Checks that a stored pubkey field matches the passed account. - Line 31
/// The stake pool account to be created, managing staking operations and rewards.: Touches staking state: the amount locked and when it was locked. - Line 41
init,: Creates and pays for a new account. Space and payer must be specified.
programs/game/src/instructions/player/deposit.rs L13–36 @ b62f1f4 · MIT · original/// account to a newly created stake order vault, then into the pool vault. Additionally, the player receives minted/// vouchers to confirm their stake, and rewards are allocated based on the configured APR.#[derive(Accounts)]pub struct Deposit<'info> { /// The player initiating the stake, must sign the transaction. #[account(mut)] pub player: Signer<'info>, /// The global game account. #[account(mut, seeds = [GAME_SEED], bump, )] pub game: Box<Account<'info, Game>>, /// The player's token account, from which staked tokens will be deducted. #[account(mut, associated_token::mint = token_mint, associated_token::authority = player )] pub token_0_account: Box<Account<'info, TokenAccount>>, /// The player's token account, from which staked tokens will be deducted. #[account(init_if_needed, payer = player,- Line 13
/// account to a newly created stake order vault, then into the pool vault. Additionally,: Touches staking state: the amount locked and when it was locked. - Line 19
pub player: Signer<'info>,: Requires this account to have signed the transaction. - Line 23
seeds = [GAME_SEED], bump,: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 23
seeds = [GAME_SEED], bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 35
#[account(init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - Line 35
#[account(init_if_needed,: Creates and pays for a new account. Space and payer must be specified.
programs/game/src/instructions/stake/stake.rs L13–36 @ b62f1f4 · MIT · originaluse anchor_spl::associated_token::AssociatedToken;use anchor_spl::token::{self, Mint, Token, TokenAccount};use solana_program::sysvar::clock::Clock; /// The `Stake` instruction allows a player to stake tokens (shards) into the staking pool, create a stake order,/// and receive voucher tokens representing their staked assets. It involves transferring tokens from the player's/// account to a newly created stake order vault, then into the pool vault. Additionally, the player receives minted/// vouchers to confirm their stake, and rewards are allocated based on the configured APR.#[derive(Accounts)]pub struct Stake<'info> { /// The player initiating the stake, must sign the transaction. #[account(mut)] pub player: Signer<'info>, /// The global game account. #[account(mut, seeds = [GAME_SEED], bump, )] pub game: Box<Account<'info, Game>>, /// The player's data account, storing player-specific state. /// Verified by `seeds` and `has_one` constraints ensuring token_account and voucher_account association. #[account( mut,- Line 17
/// The `Stake` instruction allows a player to stake tokens (shards) into the staking pool: Touches staking state: the amount locked and when it was locked. - Line 25
pub player: Signer<'info>,: Requires this account to have signed the transaction. - Line 29
seeds = [GAME_SEED], bump,: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 29
seeds = [GAME_SEED], bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 34
/// Verified by `seeds` and `has_one` constraints ensuring token_account and voucher_accou: Checks that a stored pubkey field matches the passed account.
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 lint | prettier */*.js "*/**/*{.js,.ts}" --check |
. | anchor build | compile programs and generate IDLs |
. | anchor test | local validator + test suite |
. | cargo build | Rust workspace build |
. | cargo test | Rust tests |
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)