Full lesson
solana-buybak-fsop
Buybak.xyz Fractional Stock Ownership Plan on SOLANA (preliminary repo)
What it does
From the project README:
1. ./solana-test-validator --bpf-program solana_buybak_fsop-keypair.json solana_buybak_fsop.so 2. solana config get 1. Config File: /Users/sameer/.config/solana/cli/config.yml 2. RPC URL: http://34.224.93.52:8899 3. WebSocket URL: ws://34.224.93.52:8900/ (computed) 4. Keypair Path: /Users/sameer/gitrepo/solana/cmdline/my-solana-wallet/my-keypair.json 5. Commitment: processed 6. solana airdrop 5 (on my-keypair.json) 7. Now run test programs (NodeJS) to populate FSOP aaccounts
- Original
- purchasense/solana-buybak-fsop
- SuperStack fork
- Blockchains/solana-buybak-fsop @
ef1147c - Stars
- 0
- Last push (original)
- 2024-08-27
- Languages
- TypeScript, Rust, Shell
- Detected stack
- Native Rustweb3.js
- Categories
- Other
- Licence
- MIT
Architecture
27 source files. By extension: .ts ×16, .rs ×11.
| Top-level directory | Source files |
|---|---|
src | 27 |
Dapp: deploying
This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/solana-buybak-fsop/, 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.
src/program-rust/src/processor.rs L121–144 @ ef1147c · MIT · original // Where this is a logic error in trying to initialize the same // account more than once if !user_profile_state.is_initialized() { user_profile_state.set_initialized(); } msg!("BBK: btree_storage: {} --> {}, {}, {}, {}, {}", username, username, fullname, email, phone, address); user_profile_state.add(username, fullname, email, phone, address)?; UserProfileState::pack(user_profile_state, &mut account_data).unwrap(); Ok(())} fn call_mint_to_user_portfolio(accounts: &[AccountInfo], program_id: &Pubkey, username: String, fsop: u32, average_price: u32, stock: String) -> ProgramResult { msg!("BBK: call_mint_to_user_portfolio({} {} {} {})", username, fsop, average_price, stock); // Iterating accounts is safer than indexing let accounts_iter = &mut accounts.iter(); //////////////////// // User Mint Account ////////////////////- Line 127
msg!("BBK: btree_storage: {} --> {}, {}, {}, {}, {}", username, username, fullname, email,: Logs to the program log, which is visible in explorers and the test output. - Line 135
fn call_mint_to_user_portfolio(accounts: &[AccountInfo], program_id: &Pubkey, username: St: Mints new tokens. The mint authority must sign.
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 start | ts-node src/client/main.ts |
. | npm run lint | eslint --ext .ts src/client/* && prettier --check "src/client/**/*.ts" |
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)