Sol.College

Full lesson

CuraChain

CuraChain is a decentralized crowdfunding platform designed to connect patients in need of medical treatment with philanthropic donors. It aims to facilitate transparent and secure funding for medical cases, ensuring that contributions directly support the intended healthcare services.

What it does

From the project README:

CuraChain is a blockchain-based medical crowdfunding platform built on the Solana network. It provides a transparent, secure, and efficient way to connect patients requiring medical funding with donors worldwide, ensuring that funds reach verified patients through a robust verification and escrow system.
Original
ayman-xzy/CuraChain
SuperStack fork
Blockchains/CuraChain @ f1e49c3
Stars
3
Last push (original)
2026-02-19
Languages
Rust, TypeScript
Detected stack
Anchor
Categories
Other
Licence
MIT

Architecture

22 source files. By extension: .rs ×20, .ts ×2.

Top-level directorySource files
programs20
migrations1
tests1

On-chain programs: programs/curachain

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

ayman-xzy/CuraChain · programs/curachain/src/instructions/release_funds.rs L109–132 @ f1e49c3 · MIT · original
                associated_token: facility_token_ata.clone(),                authority: ctx.accounts.facility_address.to_account_info(),                mint: token_mint_info.to_account_info(),                system_program: ctx.accounts.system_program.to_account_info(),                token_program: ctx.accounts.token_program.to_account_info()            };            let token_cpi = ctx.accounts.associated_token.to_account_info();            let cpi_ctx = CpiContext::new(token_cpi, required_accounts);            // Call The create_idempotent function            create_idempotent(cpi_ctx)?;            require!(facility_token_ata.key() == facility_ata, CuraChainError::MismatchedFacilityAtas);             // After Creating, ====>>> Make Transfer             let transfer_accounts = TransferChecked {                from: patient_token_vault.clone(),                mint: token_mint_info.clone(),                to: facility_token_ata.clone(),                authority: ctx.accounts.multisig.to_account_info()            };            let transfer_program = ctx.accounts.token_program.to_account_info();            let seeds = &[            b"multisig",            b"escrow-authority".as_ref(),            &[ctx.accounts.multisig.multisig_bump]
  1. Line 116 let cpi_ctx = CpiContext::new(token_cpi, required_accounts);: Makes a cross-program invocation into another program.
  2. Line 119 require!(facility_token_ata.key() == facility_ata, CuraChainError::MismatchedFacilityAtas): An explicit validation that aborts the instruction with an error.
  3. Line 122 let transfer_accounts = TransferChecked {: A checked token transfer, which also verifies the mint and decimals.
  4. Line 129 let seeds = &[: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
ayman-xzy/CuraChain · programs/curachain/src/states/contexts.rs L13–36 @ f1e49c3 · MIT · original
// THE ADMIN CONFIG STRUCT #[derive(Accounts)]#[instruction(admin_address: Pubkey)]pub struct AdminConfig<'info> {    #[account(        init,        payer = initializer,        space = 8 + 32 + 1 + 1,        seeds = [b"admin", admin_address.key().as_ref()],        bump    )]    pub admin_account: Account<'info, Administrator>,     #[account(mut)]    pub initializer: Signer<'info>,     pub system_program: Program<'info, System>,}  //There should be only the administrator who can call this function to add the verifier badge to others#[derive(Accounts)]#[instruction(verifier_address: Pubkey)]
  1. Line 19 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 22 seeds = [b"admin", admin_address.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 23 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 28 pub initializer: Signer<'info>,: Requires this account to have signed the transaction.
ayman-xzy/CuraChain · programs/curachain/src/instructions/admin_override_case.rs L13–36 @ f1e49c3 · MIT · original
    // Only allow after 10 days from submission time    let now = Clock::get()?.unix_timestamp;    require!(        now >= patient_case.submission_time + ALLOWED_VERIFICATION_TIME as i64,         CuraChainError::VerifiersVerificationActive    );     // Case shouldn't already be verified    require!(!patient_case.is_verified, CuraChainError::CaseAlreadyVerified);     // Set the verification status based on admin decision    patient_case.is_verified = is_verified;     msg!("[ADMIN OVERRIDE] Case ID: {}", case_id);    msg!("[ADMIN OVERRIDE] Patient case: {}", ctx.accounts.patient_case.key());    msg!("[ADMIN OVERRIDE] Verification status set to: {}", is_verified);     // If the admin approves the case, create an escrow account    if is_verified {        create_escrow_pda(ctx)?;    }     // Emit event for tracking admin override actions    let message = format!(
  1. Line 14 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  2. Line 15 require!(: An explicit validation that aborts the instruction with an error.
  3. Line 26 msg!("[ADMIN OVERRIDE] Case ID: {}", case_id);: Logs to the program log, which is visible in explorers and the test output.
ayman-xzy/CuraChain · programs/curachain/src/instructions/initialize_admin.rs L1–23 @ f1e49c3 · MIT · original
use anchor_lang::prelude::*; use crate::states::{contexts::*, events::*};  // Let's Write Our Admin initialization instruction herepub fn initialize_admin(ctx: Context<AdminConfig>, admin_address: Pubkey) -> Result<()> {    // Now, let's get the the accounts    let admin_configuration = &mut ctx.accounts.admin_account;    // Now, we set the administrator to the signer of this instruction    admin_configuration.admin_pubkey = admin_address;    admin_configuration.is_active = true;    admin_configuration.bump =  ctx.bumps.admin_account;     let clock = Clock::get()?;     let message = format!("Admin with address {} has been initialzed", admin_address);    emit!(InitializeAdmin {        admin_address: admin_address,        timestamp: clock.unix_timestamp,        active_status: true,        message    });
  1. Line 13 admin_configuration.bump = ctx.bumps.admin_account;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  2. Line 15 let clock = Clock::get()?;: Reads on-chain time from the Clock sysvar.
  3. Line 18 emit!(InitializeAdmin {: Emits an Anchor event that clients can parse from the logs.

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 testts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
.npm run lintprettier */*.js "*/**/*{.js,.ts}" --check
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it

Used in lessons