Sol.College

Full lesson

Charity.fun

What it does

From the project README:

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
Original
amaramci/Charity.fun
SuperStack fork
Blockchains/Charity.fun @ 48e39f5
Stars
0
Last push (original)
2025-07-14
Languages
Rust, Makefile, TypeScript, CSS, DTrace, JavaScript
Detected stack
AnchorNext.js
Categories
Other
Licence
MIT

Architecture

24 source files. By extension: .rs ×11, .tsx ×10, .ts ×3.

Top-level directorySource files
contracts11
components8
(root)2
app2
lib1

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/charity-fun/. 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.

amaramci/Charity.fun · contracts/src/instructions/add_liquidity.rs L61–84 @ 48e39f5 · MIT · original
    pub global_account: AccountInfo<'info>,     #[account(        init_if_needed,        payer = user,        space = LiquidityProvider::ACCOUNT_SIZE,        seeds = [LiquidityProvider::SEED_PREFIX.as_bytes(), pool.key().as_ref(), user.key().as_ref()],        bump,    )]    pub liquidity_provider_account: Box<Account<'info, LiquidityProvider>>,     #[account(mut)]    pub mint_token_one: Box<Account<'info, Mint>>,     #[account(        init,        payer = user,        associated_token::mint = mint_token_one,        associated_token::authority = global_account    )]    pub pool_token_account_one: Box<Account<'info, TokenAccount>>,     // #[account(    //     mut,
  1. Line 64 init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
  2. Line 67 seeds = [LiquidityProvider::SEED_PREFIX.as_bytes(), pool.key().as_ref(), user.key().as_ref: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 68 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 73 pub mint_token_one: Box<Account<'info, Mint>>,: Mints new tokens. The mint authority must sign.
  5. Line 76 init,: Creates and pays for a new account. Space and payer must be specified.
amaramci/Charity.fun · contracts/src/state.rs L385–408 @ 48e39f5 · MIT · original
            &mut Account<'info, TokenAccount>,            &mut Account<'info, TokenAccount>,        ),        token_two_accounts: (            &mut Account<'info, Mint>,            &mut AccountInfo<'info>,            &mut Signer<'info>,        ),        amount: u64,        style: u64,        bump: u8,        authority: &Signer<'info>,        token_program: &Program<'info, Token>,        system_program: &Program<'info, System>,    ) -> Result<()> {        if amount <= 0 {            return err!(CustomError::InvalidAmount);        }        msg!("Mint: {:?} ", token_one_accounts.0.key());        msg!(            "Swap: {:?} {:?} {:?}",            authority.key(),            style,            amount
  1. Line 391 &mut Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 395 bump: u8,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 401 return err!(CustomError::InvalidAmount);: An explicit validation that aborts the instruction with an error.
  4. Line 403 msg!("Mint: {:?} ", token_one_accounts.0.key());: Logs to the program log, which is visible in explorers and the test output.
amaramci/Charity.fun · contracts/src/instructions/swap.rs L61–84 @ 48e39f5 · MIT · original
        seeds = [b"global"],        bump,    )]    pub global_account: AccountInfo<'info>,     #[account(mut)]    pub mint_token_one: Box<Account<'info, Mint>>,     #[account(        mut,        associated_token::mint = mint_token_one,        associated_token::authority = global_account    )]    pub pool_token_account_one: Box<Account<'info, TokenAccount>>,     #[account(        mut,        associated_token::mint = mint_token_one,        associated_token::authority = user,    )]    pub user_token_account_one: Box<Account<'info, TokenAccount>>,     #[account(mut)]    pub user: Signer<'info>,
  1. Line 61 seeds = [b"global"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 62 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 67 pub mint_token_one: Box<Account<'info, Mint>>,: Mints new tokens. The mint authority must sign.
  4. Line 84 pub user: Signer<'info>,: Requires this account to have signed the transaction.
amaramci/Charity.fun · contracts/src/instructions/initialize.rs L25–48 @ 48e39f5 · MIT · original
} #[derive(Accounts)]pub struct InitializeCurveConfiguration<'info> {    #[account(        init,        space = CurveConfiguration::ACCOUNT_SIZE,        payer = admin,        seeds = [CurveConfiguration::SEED.as_bytes()],        bump,    )]    pub dex_configuration_account: Box<Account<'info, CurveConfiguration>>,     /// CHECK    #[account(        mut,        seeds = [b"global"],        bump,    )]    pub global_account: AccountInfo<'info>,     #[account(mut)]    pub admin: Signer<'info>,    pub rent: Sysvar<'info, Rent>,
  1. Line 30 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 33 seeds = [CurveConfiguration::SEED.as_bytes()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 34 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 47 pub admin: Signer<'info>,: Requires this account to have signed the transaction.

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 devnext dev
.npm run startnext start
.npm run buildnext build
.npm run lintnext lint

What you could build from it

Used in lessons