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 directory | Source files |
|---|---|
contracts | 11 |
components | 8 |
(root) | 2 |
app | 2 |
lib | 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/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.
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,- Line 64
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - 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. - Line 68
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 73
pub mint_token_one: Box<Account<'info, Mint>>,: Mints new tokens. The mint authority must sign. - Line 76
init,: Creates and pays for a new account. Space and payer must be specified.
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- Line 391
&mut Signer<'info>,: Requires this account to have signed the transaction. - Line 395
bump: u8,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 401
return err!(CustomError::InvalidAmount);: An explicit validation that aborts the instruction with an error. - Line 403
msg!("Mint: {:?} ", token_one_accounts.0.key());: Logs to the program log, which is visible in explorers and the test output.
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>,- Line 61
seeds = [b"global"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 62
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 67
pub mint_token_one: Box<Account<'info, Mint>>,: Mints new tokens. The mint authority must sign. - Line 84
pub user: Signer<'info>,: Requires this account to have signed the transaction.
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>,- Line 30
init,: Creates and pays for a new account. Space and payer must be specified. - 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. - Line 34
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run dev | next dev |
. | npm run start | next start |
. | npm run build | next build |
. | npm run lint | next lint |
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)