Sol.College

Full lesson

0ktopus

What it does

From the project README:

0KTOPUS transforms API subscriptions and digital access into tradeable NFTs on Solana. Instead of recurring subscriptions, users purchase access NFTs that:
Original
jackoske/0ktopus
SuperStack fork
Blockchains/0ktopus @ 3ee9ffc
Stars
2
Last push (original)
2025-10-28
Languages
TypeScript, Rust, JavaScript, CSS
Detected stack
AnchorNext.jsweb3.js
Categories
Other
Licence
Apache-2.0

Architecture

49 source files. By extension: .ts ×22, .tsx ×17, .rs ×7, .js ×3.

Top-level directorySource files
capability-frontend28
capability-protocol13
integration-sdk4
demo-app2
access-backend2

On-chain programs: capability-protocol/programs/capability-protocol

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/0ktopus/. 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.

jackoske/0ktopus · capability-protocol/programs/capability-protocol/src/lib.rs L73–96 @ 3ee9ffc · Apache-2.0 · original
        product.active = true;        product.bump = ctx.bumps.product;        msg!("Product registered: {}", product.name);        Ok(())    }     pub fn purchase_access<'info>(        ctx: Context<'_, '_, '_, 'info, PurchaseAccess<'info>>,        purchase_nonce: u64,    ) -> Result<()> {        let product = &ctx.accounts.product;        let config = &ctx.accounts.config;        let total_price = product.price_lamports;         let platform_fee = (total_price as u128)            .checked_mul(config.fee_bps as u128)            .and_then(|v| v.checked_div(10000))            .and_then(|v| u64::try_from(v).ok())            .ok_or(CapabilityError::ArithmeticOverflow)?;         // Transfer platform fee using CPI        let cpi_context = anchor_lang::context::CpiContext::new(            ctx.accounts.system_program.to_account_info(),            anchor_lang::system_program::Transfer {
  1. Line 74 product.bump = ctx.bumps.product;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  2. Line 75 msg!("Product registered: {}", product.name);: Logs to the program log, which is visible in explorers and the test output.
  3. Line 88 .checked_mul(config.fee_bps as u128): Uses checked arithmetic so overflow fails instead of wrapping.
  4. Line 94 let cpi_context = anchor_lang::context::CpiContext::new(: Makes a cross-program invocation into another program.
jackoske/0ktopus · capability-frontend/app/components/sections/TransferSection.tsx L49–71 @ 3ee9ffc · Apache-2.0 · original
      const toAta = getAssociatedTokenAddressSync(nftMint, recipient);       const transaction = new Transaction();       // Check if recipient ATA exists      const toAccountInfo = await connection.getAccountInfo(toAta);      if (!toAccountInfo) {        transaction.add(          createAssociatedTokenAccountInstruction(            wallet.publicKey,            toAta,            recipient,            nftMint          )        );      }       transaction.add(        createTransferInstruction(fromAta, toAta, wallet.publicKey, 1)      );       transaction.feePayer = wallet.publicKey;      transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
  1. Line 67 createTransferInstruction(fromAta, toAta, wallet.publicKey, 1): An SPL token transfer through the Token Program.
  2. Line 71 transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;: Fetches a recent blockhash. Transactions expire if it gets too old.
jackoske/0ktopus · capability-protocol/programs/capability-protocol/src/state/access_state.rs L13–36 @ 3ee9ffc · Apache-2.0 · original
 impl AccessState {    pub const LEN: usize = 8 + // discriminator        32 + // nft_mint        32 + // buyer        32 + // product        1 + 4 + // remaining_uses (Option<u32>)        1 + 8 + // expires_at (Option<i64>)        8 + // purchase_nonce        1; // bump     pub fn is_valid(&self, clock: &Clock) -> bool {        // Check if expired        if let Some(expires_at) = self.expires_at {            if clock.unix_timestamp > expires_at {                return false;            }        }         // Check if uses remaining        if let Some(remaining) = self.remaining_uses {            if remaining == 0 {                return false;            }
  1. Line 22 1; // bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  2. Line 27 if clock.unix_timestamp > expires_at {: Reads on-chain time from the Clock sysvar.

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
integration-sdknpm run devtsup --watch
integration-sdknpm run buildtsup src/index.ts src/react/index.ts --format cjs,esm --dts
integration-sdknpm run testvitest
integration-sdknpm run linteslint src/
demo-app/backendnpm run devtsx watch src/index.ts
demo-app/backendnpm run startnode dist/index.js
demo-app/backendnpm run buildtsc
demo-app/backendnpm run testvitest
demo-app/backendnpm run linteslint src/
access-backendnpm run devtsx watch src/index.ts
access-backendnpm run startnode dist/index.js
access-backendnpm run buildtsc
access-backendnpm run testvitest
access-backendnpm run linteslint src/
capability-frontendnpm run devnext dev
capability-frontendnpm run startnext start

What you could build from it

Used in lessons