Sol.College

Full lesson

Fuin

What it does

From the project README:

A private key grants unlimited authority. Autonomous agents need *bounded* authority. Fuin splits the two apart: funds live in a keyless program-controlled vault, and agents get only a **scoped, on-chain-checked capability** — a budget, an allow-list, a time window, a kill-switch. If an agent is compromised or goes rogue, the blast radius is a number you chose up front.
Original
Fuin-Labs/Fuin
SuperStack fork
Blockchains/Fuin @ 2963866
Stars
0
Last push (original)
2026-05-31
Languages
TypeScript, HTML, Rust, CSS, JavaScript, Swift
Detected stack
AnchorNext.jsweb3.js
Categories
Other
Licence
MIT
Homepage
https://fuin-vault.vercel.app

Architecture

220 source files. By extension: .ts ×94, .tsx ×93, .rs ×27, .js ×6.

Top-level directorySource files
apps143
packages44
programs31
submission1
scripts1

On-chain programs: programs/fuin/programs/fuin

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

Fuin-Labs/Fuin · programs/fuin/programs/fuin/src/handlers/freeze_vault.rs L1–24 @ 2963866 · MIT · original
use anchor_lang::prelude::*; use crate::state::{Vault, VaultState}; #[derive(Accounts)]#[instruction(nonce: u64)]pub struct FreezeVault<'info> {    pub guardian: Signer<'info>,     #[account(        mut,        seeds = [b"vault", guardian.key().as_ref(), &nonce.to_le_bytes()],        bump = vault.bump,        has_one = guardian,    )]    pub vault: Account<'info, Vault>,} pub fn freeze_vault(ctx: Context<FreezeVault>, _nonce: u64) -> Result<()> {    let clock = Clock::get()?;    let vault = &mut ctx.accounts.vault;    vault.state = VaultState::Frozen;    vault.recovery.last_guardian_activity = clock.unix_timestamp;    msg!("Vault frozen");
  1. Line 8 pub guardian: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 12 seeds = [b"vault", guardian.key().as_ref(), &nonce.to_le_bytes()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 13 bump = vault.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 14 has_one = guardian,: Checks that a stored pubkey field matches the passed account.
  5. Line 20 let clock = Clock::get()?;: Reads on-chain time from the Clock sysvar.
  6. Line 24 msg!("Vault frozen");: Logs to the program log, which is visible in explorers and the test output.
Fuin-Labs/Fuin · programs/fuin/programs/fuin/src/handlers/issue_delegate.rs L1–24 @ 2963866 · MIT · original
use anchor_lang::prelude::*; use crate::state::{Delegate, Vault}; #[derive(Accounts)]#[instruction(vault_nonce: u64, delegate_nonce: u64)]pub struct IssueDelegate<'info>{    #[account(mut)]    pub guardian: Signer<'info>,     #[account(        mut,        seeds = [            b"vault",            guardian.key().as_ref(),            &vault_nonce.to_le_bytes(),        ],        bump = vault.bump,        has_one = guardian,    )]    pub vault: Account<'info, Vault>,     #[account(        init,
  1. Line 9 pub guardian: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 13 seeds = [: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 18 bump = vault.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 19 has_one = guardian,: Checks that a stored pubkey field matches the passed account.
  5. Line 24 init,: Creates and pays for a new account. Space and payer must be specified.
Fuin-Labs/Fuin · programs/fuin/programs/fuin/src/handlers/update_vault.rs L13–36 @ 2963866 · MIT · original
        mut,        seeds = [b"vault", guardian.key().as_ref(), &nonce.to_le_bytes()],        bump = vault.bump,        has_one = guardian    )]    pub vault : Account<'info, Vault>,} pub fn update_vault(    ctx: Context<UpdateVault>,    _nonce: u64,    new_daily_cap: Option<u64>,    new_per_tx_cap: Option<u64>,    new_allow_list: Option<Vec<Pubkey>>,    new_deny_list: Option<Vec<Pubkey>>,) -> Result<()> {    let clock = Clock::get()?;    let vault = &mut ctx.accounts.vault;    vault.recovery.last_guardian_activity = clock.unix_timestamp;     if let Some(cap) = new_daily_cap {        vault.policies.spending.daily_cap = cap;        msg!("Vault: Daily cap updated to {}", cap);    }
  1. Line 14 seeds = [b"vault", guardian.key().as_ref(), &nonce.to_le_bytes()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 15 bump = vault.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 16 has_one = guardian: Checks that a stored pubkey field matches the passed account.
  4. Line 29 let clock = Clock::get()?;: Reads on-chain time from the Clock sysvar.
  5. Line 35 msg!("Vault: Daily cap updated to {}", cap);: Logs to the program log, which is visible in explorers and the test output.
Fuin-Labs/Fuin · programs/fuin/programs/fuin/src/handlers/withdraw.rs L1–23 @ 2963866 · MIT · original
use anchor_lang::prelude::*; use crate::state::Vault; #[derive(Accounts)]#[instruction(nonce: u64)]pub struct Withdraw<'info>{    #[account(mut)]    pub guardian: Signer<'info>,     #[account(        mut,        seeds = [b"vault", guardian.key().as_ref(), &nonce.to_le_bytes()],        bump = vault.bump,        has_one = guardian,    )]    pub vault: Account<'info, Vault>,     pub system_program: Program<'info, System>,} pub fn withdraw(ctx:Context<Withdraw>, _nonce: u64, amount: u64)->Result<()>{    let clock = Clock::get()?;
  1. Line 9 pub guardian: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 13 seeds = [b"vault", guardian.key().as_ref(), &nonce.to_le_bytes()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 14 bump = vault.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 15 has_one = guardian,: Checks that a stored pubkey field matches the passed account.
  5. Line 23 let clock = Clock::get()?;: Reads on-chain time from the Clock sysvar.

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 devturbo run dev
.npm run buildpnpm --filter @fuin-labs/db db:generate && turbo run build
.npm run lintturbo run lint
marketing/launch-filmnpm run devnpx --yes hyperframes@0.6.63 preview
apps/agentnpm run testecho "Error: no test specified" && exit 1
apps/relayernpm run devtsx watch --env-file=.env src/index.ts
apps/relayernpm run starttsx --env-file=.env src/index.ts
apps/my-videonpm run devremotion studio
apps/my-videonpm run buildremotion bundle
apps/my-videonpm run linttsc && eslint src
apps/vaultnpm run devnext dev --port 3000
apps/vaultnpm run startnext start
apps/vaultnpm run buildnext build
apps/vaultnpm run linteslint --max-warnings 0
programs/fuinnpm run buildanchor build
programs/fuinnpm run testanchor test

What you could build from it

Used in lessons