Full lesson
CopyTraDefi
What it does
From the project README:
The landing page serves as the main entry point for users. It provides an overview of CopyTraDefi's features and benefits.
- Original
- EasyTraDefi/CopyTraDefi
- SuperStack fork
- Blockchains/CopyTraDefi @
947c287 - Stars
- 1
- Last push (original)
- 2024-10-09
- Languages
- TypeScript, JavaScript, Rust, CSS
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- DeFi
- Licence
- Apache-2.0
Architecture
49 source files. By extension: .tsx ×23, .ts ×14, .js ×11, .rs ×1.
| Top-level directory | Source files |
|---|---|
web | 29 |
Backend | 11 |
anchor | 7 |
(root) | 2 |
On-chain programs: anchor/programs/base-project
Dapp: deploying
This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/copytradefi/, once it is deployed and checked on devnet. Until then, 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.
anchor/programs/base-project/src/lib.rs L37–60 @ 947c287 · Apache-2.0 · original #[account(mut)] pub payer: Signer<'info>, #[account( init, space = 8 + BaseProject::INIT_SPACE, payer = payer )] pub base_project: Account<'info, BaseProject>, pub system_program: Program<'info, System>,}#[derive(Accounts)]pub struct CloseBaseProject<'info> { #[account(mut)] pub payer: Signer<'info>, #[account( mut, close = payer, // close account and return lamports to payer )] pub base_project: Account<'info, BaseProject>,} #[derive(Accounts)]- Line 38
pub payer: Signer<'info>,: Requires this account to have signed the transaction. - Line 41
init,: Creates and pays for a new account. Space and payer must be specified. - Line 55
close = payer, // close account and return lamports to payer: Closes the account at the end of the instruction and refunds its lamports.
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 | nx serve web |
. | npm run build | nx build web |
anchor | anchor build | compile programs and generate IDLs |
anchor | anchor test | local validator + test suite |
anchor | anchor run test | ../node_modules/.bin/nx run anchor:jest |
What you could build from it
- Fork the SuperStack copy and extend it within the DeFi gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)
- Learn the pattern first: SPL Tokens: mints, accounts and transfers