Put a timer on SOL withdrawals. Give a trusted guardian a way to stop them.
Fren is an open-source SOL vault prototype on Solana devnet. Every withdrawal waits out a delay that the owner picks when the vault is created. During that delay, the owner or a guardian can cancel the withdrawal, or the guardian can move all of the vault's SOL to a recovery address that was fixed at creation.
- Demo video: https://youtu.be/hsuiwxGGvs8
- Live devnet app: https://fren-eight.vercel.app
- Deployed on devnet. Program
BjWnCnvk9Kr5fk7KRC58hCu34cEMqmHFPGHx7jxGPa9s - Devnet test evidence. Early execution rejected with NotYetUnlocked · Guardian rescue
If someone gets the signing key of an ordinary wallet, they can move its SOL in a single transaction, usually before the owner notices. Solana transfers are final. Chainalysis identified around 26,500 Solana victims of personal-wallet compromise in 2025 (Chainalysis, 2026 crypto crime update on hacks and stolen funds).
Multisig wallets such as Squads solve a related problem, but they ask for several signatures on every transaction and are aimed at teams. Fren is for one person: routine withdrawals need only the owner's signature, and the protection comes from time plus a guardian who can stop a withdrawal but cannot take the funds.
The owner creates a vault and sets three values, none of which can be changed later: a guardian (a second wallet, such as the owner's phone or a friend), a recovery address, and a delay between 10 seconds and 30 days. SOL is held as lamports in the vault PDA (["vault", owner, vault_id as u64 LE]), above the account's rent-exempt minimum.
stateDiagram-v2
[*] --> Idle: init_vault
Idle --> Idle: deposit / plain SOL transfer
Idle --> Pending: request_withdraw (owner)
Pending --> Pending: approve(expected_nonce) (guardian)
Pending --> Executed: execute (anyone), after unlock_ts or once approved
Pending --> Cancelled: cancel (owner or guardian)
Pending --> Rescued: rescue (guardian)
Idle --> Rescued: rescue (guardian)
Executed --> Idle: pending cleared
Cancelled --> Idle: pending cleared
Rescued --> Idle: pending cleared, vault stays open
A vault holds at most one pending request. Executed, Cancelled and Rescued are outcomes, not stored states: each one clears pending, and the vault can be used again.
| Instruction | Signer | What it does |
|---|---|---|
init_vault(vault_id, guardian, recovery, delay_secs) |
owner (pays rent) | Creates the vault PDA. Rejects a guardian or recovery address equal to the owner, the vault PDA or the default address (InvalidGuardian, InvalidRecovery). Rejects a delay outside 10 s to 30 days (InvalidDelay). The guardian may also be the recovery address. |
deposit(amount) |
any depositor | Transfers amount lamports into the vault via the System Program. A plain System Program transfer to the vault PDA works too (the web app uses that), but emits no Fren event. |
request_withdraw(amount, destination) |
owner | Records Pending { amount, destination, unlock_ts = now + delay, approved: false, request_nonce }. Fails if a request is already pending (PendingExists), if amount is 0, if destination is the vault, or if amount exceeds the withdrawable balance. Each request takes the next value of the vault's request_nonce counter (first request = 1). |
cancel() |
owner or guardian | Clears the pending request. Anyone else gets Unauthorized. |
execute() |
anyone (no signer role) | Sends the pending amount to the recorded destination. The destination account passed in must match (DestinationMismatch). Before unlock_ts and without guardian approval it fails with NotYetUnlocked (6000). Re-checks the withdrawable balance. |
rescue() |
guardian | Sends the whole withdrawable balance to the stored recovery address (RecoveryMismatch for any other account) and clears any pending request. Works with or without a pending request. The vault stays open. |
approve(expected_nonce) |
guardian | Marks the pending request as approved so it can be executed before unlock_ts. expected_nonce must equal pending.request_nonce, otherwise StaleApproval. This binds the approval to the request the guardian reviewed: if the request is cancelled and replaced before the approval lands, the new request has a new nonce and the approval fails. |
Every instruction emits an Anchor event (VaultCreated, Deposited, WithdrawRequested, Cancelled, Executed, Rescued, Approved). The 14 custom errors (6000 to 6013) are in program/programs/fren/src/error.rs and the IDL at program/target/idl/fren.json (copied to app/src/idl/fren.json).
| Action | Owner | Guardian | Anyone |
|---|---|---|---|
| Create vault | yes | ||
| Deposit | yes | yes | yes |
| Request withdrawal (any destination except the vault) | yes | ||
| Cancel pending request | yes | yes | |
| Approve early execution of the reviewed request | yes | ||
| Execute after unlock (or once approved) | yes | yes | yes |
| Rescue all withdrawable SOL to the recovery address | yes | ||
| Change guardian, recovery or delay | no instruction exists |
Threat model: the owner's key is stolen. With it, an attacker can request a withdrawal to their own address, but cannot move SOL until the delay has passed. The guardian sees the pending request (in the app, or by watching WithdrawRequested events) and can cancel it, or rescue the funds to the recovery address. If the attacker keeps cancelling and re-requesting, a rescue ends that.
What the program enforces, independent of the web app:
- No SOL leaves the vault except through
execute(to the destination recorded in the request) orrescue(to the recovery address stored at creation). executebeforeunlock_tsfails unless the guardian approved that specific request (nonce-bound).- A second request cannot overwrite a pending one.
- A guardian key on its own cannot redirect funds: it can only cancel, approve the owner's request as recorded, or rescue to the fixed recovery address.
- Guardian, recovery and delay cannot be changed after creation, so a stolen owner key cannot swap them.
- The vault never drops below its rent-exempt minimum, so it cannot be closed or garbage-collected by withdrawals.
- All lamport and timestamp arithmetic is checked (
checked_add/checked_sub);unlock_tsoverflow is rejected. - PDAs are re-derived from the stored owner,
vault_idand bump on every instruction, andAccount<Vault>checks the owner program and discriminator.
- SOL only. SPL tokens and NFTs are not supported.
- Completed transfers cannot be undone. Fren only protects SOL that is inside the vault while a request is pending. A withdrawal that has already executed is final.
- Guardian collusion or a second compromise. If the attacker controls both the owner and the guardian key, the guardian can approve the attacker's request and it executes immediately. If the attacker controls both the guardian and the recovery key, a rescue sends the funds to them. Use keys that are stored separately.
- Wrong setup is permanent. Guardian and recovery are immutable. The program rejects the owner, the vault PDA and the default address, but cannot check that the guardian can actually sign or that the recovery address is one you control.
- Recipient rent minimum. A transfer to an unfunded destination or recovery account must leave it rent-exempt (about 0.00089 SOL for a plain wallet account). Below that, Solana rejects the transaction; the request and vault balance stay intact, and you can fund the recipient and retry.
- Rent stays in the vault. There is no
closeinstruction, so the vault's own rent-exempt minimum (195-byte account) is not recoverable in this version. - Upgradeable program on devnet. Whoever holds the upgrade authority could change the program's rules. Before any mainnet use, that authority would need to move to a multisig or be removed.
- Account layout changed during the hackathon (the nonce fields were added). Vaults created with an earlier build would need a migration.
- Not audited. This is a hackathon prototype for devnet. Do not use real funds.
- Browser wallet integration, including Mobile Wallet Adapter on Android, still needs device testing.
fren/
├── program/ Anchor 1.2.2 workspace
│ ├── Anchor.toml program ID for localnet and devnet; `anchor test` runs `cargo test`
│ ├── rust-toolchain.toml Rust 1.89.0
│ └── programs/fren/
│ ├── src/lib.rs 7 instructions, account contexts, rent-floor helper
│ ├── src/state.rs Vault, Pending, delay bounds, PDA seed
│ ├── src/events.rs 7 Anchor events
│ ├── src/error.rs 14 custom errors (6000 to 6013)
│ └── tests/vault.rs 24 LiteSVM tests against the compiled fren.so
├── app/ Next.js 15 (App Router, TypeScript, Tailwind v4), no backend
│ ├── src/lib/fren.ts all on-chain logic: IDL-driven instruction builders, vault decoding, error decoding
│ ├── src/lib/config.ts RPC URL and program ID
│ ├── src/app/ pages: / , /create , /vault/[address] , /vaults
│ ├── src/components/ wallet providers (Wallet Standard, Solflare, Mobile Wallet Adapter), toasts, UI
│ ├── src/idl/ fren.json + fren-types.ts copied from program/target
│ └── scripts/ sync-idl.mjs, smoke-ixs.ts, e2e-devnet.ts
├── ekip/, juri/ AI team briefs, reports and review rounds (see below)
└── LICENSE MIT
The web app simulates every transaction before the wallet popup and decodes program errors from the IDL. On /vault/[address], "Try to execute now" shows Blocked by Fren: still locked for mm:ss (NotYetUnlocked) and can send the failing transaction with skipPreflight so the rejection is visible on Explorer. /vaults lists vaults where the connected wallet is owner or guardian via getProgramAccounts with memcmp filters at offsets 8 and 40. The guardian view includes a QR code of the vault URL for opening it on a phone.
Tested with Anchor CLI 1.2.2, Solana CLI 4.1.2, Rust 1.89.0 (pinned in rust-toolchain.toml), LiteSVM 0.15.0, Node.js 20.
# Anchor and Solana CLIs must be on PATH (default install locations shown)
export PATH="$HOME/.cargo/bin:$HOME/.local/share/solana/install/active_release/bin:$PATH"
cd program
anchor build # writes target/deploy/fren.so and target/idl/fren.json
cargo test --locked # 24 LiteSVM testsThe tests load target/deploy/fren.so and stop with a rebuild instruction if it is missing or older than the program sources, so always run anchor build first. The program keypair in target/deploy/ is git-ignored; on a fresh clone do not run anchor keys sync unless you intend to deploy your own copy under a new program ID.
cd app
npm install
npm run sync-idl # copies ../program/target/idl/fren.json and types into src/idl/ (after anchor build)
npm run dev # http://localhost:3000
npx tsx scripts/smoke-ixs.ts # optional: builds every instruction offline from the IDLThe committed src/idl/ already matches the current program, so sync-idl is only needed after changing the program. Optional variables in app/.env.local (no secrets needed):
| Variable | Default | Purpose |
|---|---|---|
NEXT_PUBLIC_RPC_URL |
https://api.devnet.solana.com |
A private devnet RPC avoids public rate limits |
NEXT_PUBLIC_PROGRAM_ID |
address in src/idl/fren.json |
Only if you deploy under a different program ID |
Use devnet SOL from a faucet and test wallets only.
program/programs/fren/tests/vault.rs, 24 tests, all passing with cargo test --locked:
- Happy path: plain transfer deposit, request, permissionless execute exactly at unlock
- Execute one second early fails with
NotYetUnlockedand keeps the request depositinstruction works from any signer- Non-owner cannot request
- Guardian cancels; a cancelled request cannot execute
- Owner cancels and requests again (approval flag resets)
- Stale approval (old nonce) is rejected and the replacement request stays locked until its own unlock time
- Stranger cannot cancel
- Guardian rescues the full withdrawable balance, vault stays open, pending cleared
- Non-guardian cannot rescue
- Rescue to a wrong recovery account is rejected
- Execute to a wrong destination is rejected after unlock
- A second request cannot overwrite the first
- Only guardian approval allows early execute
- A request cannot spend the vault's rent reserve
- Cancel, approve and execute require a pending request
- Delay bounds (10 s and 30 days) are enforced; guardian can be the recovery address
- Owner, vault and default address are invalid guardians
- Owner, vault and default address are invalid recovery addresses
- Zero amount and the vault as destination are rejected
unlock_tsoverflow is rejected- Withdrawal to an unfunded destination at exactly the recipient rent minimum
- A rescue below the recipient rent minimum fails safely and succeeds after funding the recovery address
- Every instruction emits its event with the expected fields
Run the live devnet test with cd app && npx tsx scripts/e2e-devnet.ts. It uses the web app's instruction builders, funds test wallets with 0.214 devnet SOL plus a transaction fee from ~/.config/solana/fren-devnet.json, and prints Explorer links.
All code in this repository was written on 27–28 November 2026 during the Dev3pack hackathon; there is no pre-existing code. Development was AI-assisted: a human lead directed an AI team (OpenAI Codex wrote the Anchor program and tests; Claude Code built the web app after an Antigravity/Gemini start), and each output is scored by a reviewer from a different model family, with fix rounds until it passes (the program passed; the web app review is still in its fix round). The briefs, agent reports and review rounds are kept in ekip/ and juri/. For example, the nonce-bound approve came from a review finding that an argument-less approval could be redirected to a replacement request.
- SPL token vaults.
- Guardian alerts on
WithdrawRequestedthat link to a Blink for one-tap cancel or rescue. - x402 integrations that keep the withdrawal delay in place.
- Test and polish the guardian flow on Solana Seeker.
<TEAM_MEMBER_NAME>·<ROLE>·<CONTACT>