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 directory | Source files |
|---|---|
app | 25 |
tests | 4 |
cli | 1 |
programs | 1 |
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.
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)?;- Line 121
let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 122
require!(: An explicit validation that aborts the instruction with an error. - Line 125
.checked_add(stream.lock_offset_secs): Uses checked arithmetic so overflow fails instead of wrapping. - 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. - Line 131
let cpi_ctx = CpiContext::new(: Makes a cross-program invocation into another program. - Line 139
token::transfer(cpi_ctx, stake_amount)?;: An SPL token transfer through the Token Program.
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;- Line 255
async submitPrediction(streamPda, choice, stake) {: Touches staking state: the amount locked and when it was locked. - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run build | anchor build |
. | npm run test | anchor test |
app | npm run dev | next dev |
app | npm run start | next start |
app | npm run build | next build |
app | npm run test | echo "Frontend tests are TBD" |
app | npm run lint | eslint |
. | anchor build | compile programs and generate IDLs |
. | anchor test | local validator + test suite |
. | anchor run test | npx ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts |
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)