Sol.College

Full lesson

Solana-AI-platform

What it does

From the project README:

cand un utilizator isi creaza cont pe platforma i se deschide un solana account ??? (poate sa aiba account -> verifica daca exista contul)
Original
micuami/Solana-AI-platform
SuperStack fork
Blockchains/Solana-AI-platform @ 61e5ca8
Stars
0
Last push (original)
2025-10-26
Languages
Python, JavaScript, CSS, Rust, Mako, TypeScript
Detected stack
Anchor
Categories
AI & Agents
Licence
MIT

Architecture

37 source files. By extension: .py ×19, .jsx ×12, .js ×4, .ts ×1, .rs ×1.

Top-level directorySource files
backend19
frontend14
blockchain4

On-chain programs: blockchain/programs/blockchain

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/solana-ai-platform/. 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.

micuami/Solana-AI-platform · blockchain/programs/blockchain/src/lib.rs L37–60 @ 61e5ca8 · MIT · original
    }     pub fn rent_model(ctx: Context<RentModel>) -> Result<()> {        let model = &mut ctx.accounts.model;        require!(model.is_available, ErrorCode::ModelNotAvailable);         let renter = &ctx.accounts.renter;        let uploader = &ctx.accounts.uploader;         // Transfer SOL from renter -> uploader (CPI to system program)        let ix = system_instruction::transfer(&renter.key(), &uploader.key(), model.price_lamports);        invoke(            &ix,            &[                renter.to_account_info(),                uploader.to_account_info(),                ctx.accounts.system_program.to_account_info(),            ],        )?;         model.times_rented = model.times_rented.checked_add(1).ok_or(ErrorCode::MathOverflow)?;        let now = Clock::get()?.unix_timestamp;        emit!(ModelRented {            model: model.key(),
  1. Line 41 require!(model.is_available, ErrorCode::ModelNotAvailable);: An explicit validation that aborts the instruction with an error.
  2. Line 48 invoke(: Makes a cross-program invocation into another program.
  3. Line 57 model.times_rented = model.times_rented.checked_add(1).ok_or(ErrorCode::MathOverflow)?;: Uses checked arithmetic so overflow fails instead of wrapping.
  4. Line 58 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  5. Line 59 emit!(ModelRented {: Emits an Anchor event that clients can parse from the logs.
micuami/Solana-AI-platform · blockchain/clients/rent_model.js L121–144 @ 61e5ca8 · MIT · original
    const programPubkey = new PublicKey(programId);    const connection = new Connection(rpcUrl, "confirmed");    const wallet = new anchor.Wallet(keypair);    const provider = new anchor.AnchorProvider(connection, wallet, anchor.AnchorProvider.defaultOptions());    anchor.setProvider(provider);     const program = new anchor.Program(idl, programPubkey, provider);     // derive PDA: seeds = ["model", model_hash_bytes]    const seedBytes = Buffer.from(modelHashHex, "hex");    if (seedBytes.length !== 32) {      exitJSON({ success: false, error: "model_hash_hex must be 32 bytes (64 hex chars)" }, 1);    }    const [modelPda] = await PublicKey.findProgramAddress([Buffer.from("model"), seedBytes], program.programId);     // fetch model account to ensure exists and get uploader pubkey    let modelAccount;    try {      modelAccount = await program.account.model.fetch(modelPda);    } catch (e) {      exitJSON({ success: false, error: "Model account not found on-chain for given hash", details: e.message || String(e) }, 1);    }     // uploader pubkey depends on your account layout; we expect a pubkey field named `uploader`
  1. Line 129 // derive PDA: seeds = ["model", model_hash_bytes]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 134 const [modelPda] = await PublicKey.findProgramAddress([Buffer.from("model"), seedBytes], p: Derives a PDA from seeds and the program ID and returns the address with its canonical bump.

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
blockchainnpm run lintprettier */*.js "*/**/*{.js,.ts}" --check
frontendnpm run devvite
frontendnpm run buildvite build
frontendnpm run linteslint .
blockchainanchor buildcompile programs and generate IDLs
blockchainanchor testlocal validator + test suite
blockchainanchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts

What you could build from it