Sol.College

Full lesson

Cleara

Selling days for hard-to-sell tokenized assets: everyone places orders before a deadline, then all matches trade at one price. Live demo on Solana Devnet.

What it does

From the project README:

Live demo: **https://cleara-ten.vercel.app** · Videos: pitch · product demo · Docs: this README and the in-app Developers page · Submission: Colosseum Crypto World's Fair (not linked yet)
Original
CryptoZephyr/Cleara
SuperStack fork
Blockchains/Cleara @ e17ce9c
Stars
0
Last push (original)
2026-10-12
Languages
TypeScript, Rust, CSS, HTML, JavaScript
Detected stack
Anchorweb3.js
Categories
Infrastructure & Tooling
Licence
MIT
Homepage
https://cleara-ten.vercel.app

Architecture

47 source files. By extension: .ts ×27, .tsx ×17, .rs ×2, .js ×1.

Top-level directorySource files
app44
programs2
tests1

On-chain programs: programs/cleara

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/cleara/. 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.

CryptoZephyr/Cleara · programs/cleara/src/lib.rs L589–612 @ e17ce9c · MIT · original
    pub base_vault: Box<InterfaceAccount<'info, TokenAccount>>,    #[account(        init,        payer = issuer,        seeds = [QUOTE_VAULT_SEED, auction.key().as_ref()],        bump,        token::mint = quote_mint,        token::authority = auction,        token::token_program = quote_token_program    )]    pub quote_vault: Box<InterfaceAccount<'info, TokenAccount>>,    #[account(token::mint = quote_mint, token::token_program = quote_token_program)]    pub fee_account: Box<InterfaceAccount<'info, TokenAccount>>,    pub base_token_program: Interface<'info, TokenInterface>,    pub quote_token_program: Interface<'info, TokenInterface>,    pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct PlaceOrder<'info> {    pub owner: Signer<'info>,    #[account(mut, has_one = base_mint, has_one = quote_mint)]    pub auction: Box<Account<'info, Auction>>,    pub base_mint: Box<InterfaceAccount<'info, Mint>>,
  1. Line 591 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 593 seeds = [QUOTE_VAULT_SEED, auction.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 594 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 609 pub owner: Signer<'info>,: Requires this account to have signed the transaction.
  5. Line 610 #[account(mut, has_one = base_mint, has_one = quote_mint)]: Checks that a stored pubkey field matches the passed account.
CryptoZephyr/Cleara · app/server/operator.ts L1–24 @ e17ce9c · MIT · original
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";import {  ComputeBudgetProgram,  Connection,  Keypair,  PublicKey,  SystemProgram,  Transaction,  TransactionInstruction,  type AccountMeta,} from "@solana/web3.js";import {  TOKEN_2022_PROGRAM_ID,  TOKEN_PROGRAM_ID,  createAssociatedTokenAccountIdempotentInstruction,  createMintToInstruction,  createTransferCheckedInstruction,  getAssociatedTokenAddressSync,} from "@solana/spl-token";import { createHash } from "node:crypto";import idl from "../src/idl/cleara.json" with { type: "json" };import type { Cleara } from "../src/idl/cleara";import { CONFIG, type AssetConfig } from "../shared/config";import { SIDE_BUY, SIDE_EMPTY, auctionPda, parseAtoms, quoteCeil, vaultPdas } from "../shared/cleara";
  1. Line 3 ComputeBudgetProgram,: Sets the compute-unit limit or price (priority fee).
  2. Line 13 TOKEN_2022_PROGRAM_ID,: Targets the Token-2022 program instead of the original Token Program.
  3. Line 16 createMintToInstruction,: Mints new tokens. The mint authority must sign.
  4. Line 17 createTransferCheckedInstruction,: A checked token transfer, which also verifies the mint and decimals.
CryptoZephyr/Cleara · app/src/lib/chain.ts L253–276 @ e17ce9c · MIT · original
  const o = a.orders[slot];  return [    await program.methods      .refundExpired(slot)      .accountsPartial({ ...common(a), ...ownerAccounts(a, new PublicKey(o.owner)) })      .instruction(),  ];} export async function sendIxs(wallet: WalletContextState, ixs: TransactionInstruction[]) {  if (!wallet.publicKey) throw new Error("Connect a wallet first.");  const tx = new Transaction().add(...ixs);  tx.feePayer = wallet.publicKey;  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");  tx.recentBlockhash = blockhash;  const signature = await wallet.sendTransaction(tx, connection, { maxRetries: 5 });  const res = await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, "confirmed");  if (res.value.err) throw new Error(`Transaction failed onchain: ${JSON.stringify(res.value.err)}`);  return signature;} export async function tokenBalance(mint: string, owner: PublicKey, program2022: boolean): Promise<bigint> {  const ata = getAssociatedTokenAddressSync(new PublicKey(mint), owner, true, program2022 ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID);  try {
  1. Line 266 const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed: Fetches a recent blockhash. Transactions expire if it gets too old.
  2. Line 268 const signature = await wallet.sendTransaction(tx, connection, { maxRetries: 5 });: Submits the signed transaction to the cluster.
  3. Line 275 const ata = getAssociatedTokenAddressSync(new PublicKey(mint), owner, true, program2022 ? : Targets the Token-2022 program instead of the original Token Program.
CryptoZephyr/Cleara · app/server/payHandler.ts L73–96 @ e17ce9c · MIT · original
        baseMint,        quoteMint,        baseVault,        quoteVault,        ownerBase,        ownerQuote,        baseTokenProgram: TOKEN_2022_PROGRAM_ID,        quoteTokenProgram: TOKEN_PROGRAM_ID,      })      .instruction()  );  tx.feePayer = account;  tx.recentBlockhash = (await conn.getLatestBlockhash("confirmed")).blockhash;  const verb = side === SIDE_BUY ? "Buy" : "Sell";  return {    transaction: tx.serialize({ requireAllSignatures: false, verifySignatures: false }).toString("base64"),    message: `${verb} limit order on Cleara (Solana Devnet, test tokens only). Funds lock in the event escrow until settlement.`,  };} export default async function handler(req: VercelRequest, res: VercelResponse) {  cors(res);  if (req.method === "OPTIONS") return res.status(204).end();  if (req.method === "GET") return res.json({ label: "Cleara (Devnet)", icon: ICON });
  1. Line 79 baseTokenProgram: TOKEN_2022_PROGRAM_ID,: Targets the Token-2022 program instead of the original Token Program.
  2. Line 85 tx.recentBlockhash = (await conn.getLatestBlockhash("confirmed")).blockhash;: Fetches a recent blockhash. Transactions expire if it gets too old.

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
.npm run lintprettier */*.ts --check
appnpm run devvite
appnpm run buildtsc -b && vite build
appnpm run linteslint .
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it

Used in lessons