Full lesson
Streampay
Privacy-first cross-chain subscriptions on Solana.
What it does
From the project README:
StreamPay isn't just another payment gateway; it's the missing link between the sovereign freedom of decentralized finance and the non-negotiable privacy of global commerce. We've built the infrastructure that finally allows businesses to scale on-chain without stripping away their competitive confidentiality.
- Original
- rohan911438/Streampay
- SuperStack fork
- Blockchains/Streampay @
f77924b - Stars
- 0
- Last push (original)
- 2026-05-02
- Languages
- TypeScript, HTML, JavaScript, Rust, PowerShell, Batchfile
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- PaymentsInfrastructure & Tooling
- Licence
- MIT
- Homepage
- https://streampay-web.vercel.app
Architecture
99 source files. By extension: .ts ×60, .js ×19, .tsx ×18, .rs ×2.
| Top-level directory | Source files |
|---|---|
apps | 76 |
streampay-sdk | 8 |
packages | 7 |
scripts | 5 |
contracts | 2 |
scratch | 1 |
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/streampay/. 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.
contracts/payment-router/src/lib.rs L49–72 @ f77924b · MIT · original require!( authority == payment_record.user || authority == payment_record.merchant || authority.to_bytes() == BACKEND_AUTHORITY_BYTES, PaymentRouterError::Unauthorized ); payment_record.execution_reference = execution_reference; payment_record.status = PaymentStatus::Completed; Ok(()) }} #[derive(Accounts)]pub struct CreatePayment<'info> { #[account(mut)] pub user: Signer<'info>, #[account(init, payer = user, space = PaymentRecord::SPACE)] pub payment_record: Account<'info, PaymentRecord>, pub system_program: Program<'info, System>,} #[derive(Accounts)]- Line 49
require!(: An explicit validation that aborts the instruction with an error. - Line 66
pub user: Signer<'info>,: Requires this account to have signed the transaction. - Line 67
#[account(init, payer = user, space = PaymentRecord::SPACE)]: Creates and pays for a new account. Space and payer must be specified.
contracts/subscription-manager/src/lib.rs L37–59 @ f77924b · MIT · original require!( authority == payment.user || authority == payment.merchant || authority.to_bytes() == BACKEND_AUTHORITY_BYTES, SubscriptionError::Unauthorized ); require!(payment.merchant == plan.merchant, SubscriptionError::InvalidMerchant); require!(payment.amount >= plan.amount, SubscriptionError::InvalidAmount); require!(payment.is_confirmed, SubscriptionError::PaymentNotConfirmed); require!(payment.plan_id == plan.plan_id, SubscriptionError::InvalidPlan); let now = Clock::get()?.unix_timestamp; let subscription = &mut ctx.accounts.subscription; subscription.user = payment.user; subscription.merchant = plan.merchant; subscription.plan_id = plan.plan_id; subscription.amount = plan.amount; subscription.payment_record = payment_record; subscription.start_timestamp = now; subscription.end_timestamp = now .checked_add(plan.duration_seconds) .ok_or(SubscriptionError::TimestampOverflow)?; subscription.status = SubscriptionStatus::Active;- Line 37
require!(: An explicit validation that aborts the instruction with an error. - Line 48
let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 57
.checked_add(plan.duration_seconds): Uses checked arithmetic so overflow fails instead of wrapping.
packages/solana/src/payment-router.ts L133–156 @ f77924b · MIT · original const transaction = new Transaction().add(instruction); const signature = await sendAndConfirmTransaction(connection, transaction, [ authority, ]); return signature;} /** * Derive the PDA for a payment record */export function derivePaymentRecordPDA( user: PublicKey, merchant: PublicKey, seed: string): PublicKey { const [pda] = PublicKey.findProgramAddressSync( [ Buffer.from("payment_record"), user.toBuffer(), merchant.toBuffer(), Buffer.from(seed), ],- Line 135
const signature = await sendAndConfirmTransaction(connection, transaction, [: Submits the signed transaction to the cluster. - Line 150
const [pda] = PublicKey.findProgramAddressSync(: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.
packages/solana/src/subscription-manager.ts L169–192 @ f77924b · MIT · original { pubkey: subscriptionPlanPubkey, isSigner: false, isWritable: false }, { pubkey: paymentRecordPubkey, isSigner: false, isWritable: false }, ], data: instructionData, }; const transaction = new Transaction().add(instruction); const signature = await sendAndConfirmTransaction(connection, transaction, [ authority, ]); return signature;} /** * Derive the PDA for a subscription plan */export function deriveSubscriptionPlanPDA( merchant: PublicKey, planId: number): PublicKey { const [pda] = PublicKey.findProgramAddressSync( [ Buffer.from("subscription_plan"),- Line 176
const signature = await sendAndConfirmTransaction(connection, transaction, [: Submits the signed transaction to the cluster. - Line 190
const [pda] = PublicKey.findProgramAddressSync(: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.
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 | npm run --workspace web dev |
. | npm run start | npm run --workspace web start |
. | npm run build | npm run --workspace web build |
apps/web | npm run dev | next dev -p 3000 |
apps/web | npm run start | next start |
apps/web | npm run build | next build |
streampay-sdk | npm run build | tsc |
streampay-sdk | npm run test | jest |
streampay-sdk | npm run lint | eslint src --ext .ts |
What you could build from it
- Fork the SuperStack copy and extend it within the Payments gaps listed on the idea page.
- Learn the pattern first: Solana Pay
- Learn the pattern first: SPL Tokens: mints, accounts and transfers
- Learn the pattern first: Blinks and Solana Actions