Sol.College

Full lesson

cyphercast

What it does

From the project README:

[](https://solana.com) [](https://www.anchor-lang.com/) [](./docs/TESTING.md) [](./docs/MVP.md) [](./CHANGELOG.md)
Original
chankung9/cyphercast
SuperStack fork
Blockchains/cyphercast @ c7527d4
Stars
1
Last push (original)
2025-11-08
Languages
TypeScript, Rust, JavaScript, MDX, Shell, CSS
Detected stack
AnchorNext.jsweb3.js
Categories
Other
Licence
MIT

Architecture

31 source files. By extension: .ts ×19, .tsx ×10, .js ×1, .rs ×1.

Top-level directorySource files
app25
tests4
cli1
programs1

On-chain programs: programs/cyphercast

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/cyphercast/. 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.

chankung9/cyphercast · programs/cyphercast/src/lib.rs L121–144 @ c7527d4 · MIT · original
        let now = Clock::get()?.unix_timestamp;        require!(            now < stream                .start_time                .checked_add(stream.lock_offset_secs)                .ok_or(CypherCastError::Overflow)?,            CypherCastError::StreamLocked        );         // Transfer SPL tokens from viewer's ATA to vault ATA for prediction stake        let cpi_ctx = CpiContext::new(            ctx.accounts.token_program.to_account_info(),            Transfer {                from: ctx.accounts.viewer_token_account.to_account_info(),                to: ctx.accounts.vault_token_account.to_account_info(),                authority: ctx.accounts.viewer.to_account_info(),            },        );        token::transfer(cpi_ctx, stake_amount)?;         vault.total_deposited = vault            .total_deposited            .checked_add(stake_amount)            .ok_or(CypherCastError::Overflow)?;
  1. Line 121 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  2. Line 122 require!(: An explicit validation that aborts the instruction with an error.
  3. Line 125 .checked_add(stream.lock_offset_secs): Uses checked arithmetic so overflow fails instead of wrapping.
  4. Line 130 // Transfer SPL tokens from viewer's ATA to vault ATA for prediction stake: Touches staking state: the amount locked and when it was locked.
  5. Line 131 let cpi_ctx = CpiContext::new(: Makes a cross-program invocation into another program.
  6. Line 139 token::transfer(cpi_ctx, stake_amount)?;: An SPL token transfer through the Token Program.
chankung9/cyphercast · cli/direct-cli.js L241–264 @ c7527d4 · MIT · original
      log(`   Participant PDA: ${participantPda.toString()}`, 'cyan');            return { participantPda, signature };          } catch (error) {      log(`\n❌ Failed to join stream: ${error.message}`, 'red');      if (error.logs) {        log('Program logs:', 'yellow');        error.logs.forEach(l => log(`   ${l}`, 'reset'));      }      throw error;    }  }   async submitPrediction(streamPda, choice, stake) {    try {      log('\n🎯 Submitting Prediction...', 'yellow');      log('─'.repeat(50), 'cyan');            const streamPubkey = new PublicKey(streamPda);      const [predictionPda, bump] = await this.derivePredictionPDA(streamPubkey, this.keypair.publicKey);            // Convert choice to u8 (0-255)      const choiceU8 = typeof choice === 'string' ? parseInt(choice) || 0 : choice;
  1. Line 255 async submitPrediction(streamPda, choice, stake) {: Touches staking state: the amount locked and when it was locked.
  2. Line 261 const [predictionPda, bump] = await this.derivePredictionPDA(streamPubkey, this.keypair.pu: 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.

DirectoryCommandRuns
.npm run buildanchor build
.npm run testanchor test
appnpm run devnext dev
appnpm run startnext start
appnpm run buildnext build
appnpm run testecho "Frontend tests are TBD"
appnpm run linteslint
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testnpx ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts

What you could build from it