Full lesson
CredenceChain
CredenceChain
- Original
- codebaseonline/CredenceChain
- SuperStack fork
- Blockchains/CredenceChain @
f70eff8 - Stars
- 0
- Last push (original)
- 2024-04-08
- Languages
- Rust, Vue, JavaScript, HTML
- Detected stack
- not detected
- Categories
- Other
- Licence
- BSD-3-Clause
Architecture
5 source files. By extension: .js ×3, .rs ×2.
| Top-level directory | Source files |
|---|---|
(root) | 5 |
Dapp: deploying
This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/credencechain/, 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.
lib.rs L25–48 @ f70eff8 · BSD-3-Clause · original let token_account = next_account_info(account_iter)?; let mint_authority = next_account_info(account_iter)?; // Ensure the mint_authority is correct (you can implement your own authorization logic) // Mint new tokens let mut token_data = token_account.try_borrow_mut_data()?; let mut token_balance = u64::from_le_bytes(*token_data); token_balance = token_balance.checked_add(amount).ok_or(ProgramError::Overflow)?; token_data.copy_from_slice(&token_balance.to_le_bytes()); msg!("GreenTokens minted successfully!"); Ok(()) } fn transfer( program_id: &Pubkey, accounts: &[AccountInfo], from_amount: u64, to_account: &Pubkey, ) -> ProgramResult { let account_iter = &mut accounts.iter(); let from_account = next_account_info(account_iter)?;- Line 34
token_balance = token_balance.checked_add(amount).ok_or(ProgramError::Overflow)?;: Uses checked arithmetic so overflow fails instead of wrapping. - Line 37
msg!("GreenTokens minted successfully!");: Logs to the program log, which is visible in explorers and the test output.
How to run
No package.json, Anchor.toml, Cargo.toml, go.mod or Makefile was found near the root. See the project README.
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)