Sol.College

Full lesson

ClearWatch

What it does

From the project README:

[](https://clearwatch.pages.dev) [](https://explorer.solana.com/address/FDMGN1Gp62gK1TAnVvq2DM4HV6BhFwJ9Me5djLVKEKgB?cluster=devnet) [](LICENSE)
Original
VJyou/ClearWatch
SuperStack fork
Blockchains/ClearWatch @ 2582105
Stars
0
Last push (original)
2026-05-08
Languages
HTML, Rust, Shell, TypeScript
Detected stack
Anchorweb3.js
Categories
Other
Licence
MIT

Architecture

13 source files. By extension: .rs ×12, .ts ×1.

Top-level directorySource files
programs12
migrations1

On-chain programs: programs/clearwatch

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

VJyou/ClearWatch · programs/clearwatch/src/instructions/slash_reporter.rs L1–24 @ 2582105 · MIT · original
use anchor_lang::prelude::*;use crate::state::RiskEntry;use crate::error::ClearWatchError; #[derive(Accounts)]#[instruction(flagged_address: Pubkey)]pub struct SlashReporter<'info> {    #[account(mut)]    pub authority: Signer<'info>,     #[account(        mut,        close = authority,        seeds = [b"risk_entry", flagged_address.as_ref()],        bump,    )]    pub risk_entry: Account<'info, RiskEntry>,     /// CHECK: The vault PDA that holds staked SOL — slashed to authority    #[account(        mut,        seeds = [b"stake_vault", flagged_address.as_ref()],        bump,    )]
  1. Line 9 pub authority: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 13 close = authority,: Closes the account at the end of the instruction and refunds its lamports.
  3. Line 14 seeds = [b"risk_entry", flagged_address.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  4. Line 15 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  5. Line 19 /// CHECK: The vault PDA that holds staked SOL — slashed to authority: Touches staking state: the amount locked and when it was locked.
VJyou/ClearWatch · programs/clearwatch/src/instructions/report_address.rs L1–24 @ 2582105 · MIT · original
use anchor_lang::prelude::*;use anchor_lang::system_program;use crate::state::RiskEntry;use crate::error::ClearWatchError; #[derive(Accounts)]#[instruction(flagged_address: Pubkey, incident_type: String)]pub struct ReportAddress<'info> {    #[account(mut)]    pub reporter: Signer<'info>,     #[account(        init,        payer = reporter,        space = RiskEntry::SPACE,        seeds = [b"risk_entry", flagged_address.as_ref()],        bump,    )]    pub risk_entry: Account<'info, RiskEntry>,     /// CHECK: The vault PDA that holds staked SOL    #[account(        mut,        seeds = [b"stake_vault", flagged_address.as_ref()],
  1. Line 10 pub reporter: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 13 init,: Creates and pays for a new account. Space and payer must be specified.
  3. Line 16 seeds = [b"risk_entry", flagged_address.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  4. Line 17 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  5. Line 21 /// CHECK: The vault PDA that holds staked SOL: Touches staking state: the amount locked and when it was locked.
VJyou/ClearWatch · programs/clearwatch/src/instructions/check_and_prove.rs L1–24 @ 2582105 · MIT · original
use anchor_lang::prelude::*;use crate::state::{RiskEntry, InnocenceProof, evaluate_risk};use crate::error::ClearWatchError; #[derive(Accounts)]#[instruction(counterparty: Pubkey, amount: u64, purpose: String)]pub struct CheckAndProve<'info> {    #[account(mut)]    pub agent: Signer<'info>,     /// Risk entry for the counterparty (optional — may not exist)    #[account(        seeds = [b"risk_entry", counterparty.as_ref()],        bump,    )]    pub risk_entry: Option<Account<'info, RiskEntry>>,     #[account(        init,        payer = agent,        space = InnocenceProof::SPACE,        seeds = [b"innocence_proof", agent.key().as_ref(), counterparty.as_ref()],        bump,    )]
  1. Line 9 pub agent: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 13 seeds = [b"risk_entry", counterparty.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 14 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 19 init,: Creates and pays for a new account. Space and payer must be specified.
VJyou/ClearWatch · programs/clearwatch/src/instructions/check_only.rs L1–24 @ 2582105 · MIT · original
use anchor_lang::prelude::*;use crate::state::{RiskEntry, evaluate_risk}; /// Read-only risk gate: returns (is_clear, risk_score, risk_tier_at_check)/// without writing an InnocenceProof PDA. Designed for high-throughput/// callers (DEX aggregators, bridges) that pay compute units per swap and/// don't need a per-transaction audit trail.#[derive(Accounts)]#[instruction(counterparty: Pubkey)]pub struct CheckOnly<'info> {    pub caller: Signer<'info>,     #[account(        seeds = [b"risk_entry", counterparty.as_ref()],        bump,    )]    pub risk_entry: Option<Account<'info, RiskEntry>>,} #[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug)]pub struct CheckOnlyResult {    pub is_clear: bool,    pub risk_score: u8,    pub risk_tier_at_check: u8,
  1. Line 11 pub caller: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 14 seeds = [b"risk_entry", counterparty.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 15 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.

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 */*.js "*/**/*{.js,.ts}" --check
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testcargo test
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it

Used in lessons