Formally verify Solana programs with Lean 4 proofs

An agent skill that verifies your core business logic. Your agent reads the code, writes Lean 4 proofs, and iterates until they compile. Hard sub-goals go to Leanstral, Mistral's theorem prover.

npx skills add qedgen/solana-skills

Works with Cursor, Windsurf, Claude Code, GitHub Copilot, and any agent supporting Agent Skills.

How it works

Your agent drives proof writing directly. Full code context, no lossy pipeline.

Your Code Rust / Anchor Agent reads & models SPEC.md goals & properties Lean 4 Proofs lake build Leanstral (sorry) iterate on errors
1
Your Code

Agent reads your Rust / Anchor source, existing specs, or IDLs.

2
SPEC.md

Generates security goals, state model, and formal properties from your code.

3
Lean 4 Proofs

Writes theorems, runs lake build, iterates until everything compiles.

Verified

Hard sub-goals go to Leanstral. Every theorem compiles or it doesn't ship.

Working examples

16 verified proofs across two programs. Every proof compiles via lake build.

Escrow Anchor

Token escrow for two-party trades. Initializer deposits, taker completes, or initializer cancels.

9/9 proofs verified
-- Cancel only succeeds if signer = initializer
theorem cancel_access_control
    (p_preState : ProgramState) (p_signer : Pubkey)
    (h : cancelTransition p_preState p_signer ≠ none) :
    p_signer = p_preState.escrow.initializer := by
  unfold cancelTransition at h
  split_ifs at h with h_eq
  · exact h_eq
  · contradiction
View proofs →

Percolator Pure Rust

Perpetual DEX risk engine with protected principal and lazy side indices. Non-Anchor, no_std.

7/7 proofs verified
-- Deposit preserves V >= C_tot + I
theorem deposit_conservation
    (p_s p_s' : EngineState) (p_amount : Nat)
    (h_inv : conservation p_s)
    (h : depositTransition p_s p_amount = some p_s') :
    conservation p_s' := by
  unfold depositTransition at h
  split_ifs at h with h_le
  cases h
  unfold conservation at h_inv ⊢
  dsimp only
  omega
View proofs →

Get started

1. Install the skill

npx skills add qedgen/solana-skills

2. Set your Mistral API key

export MISTRAL_API_KEY=your_key

Free from console.mistral.ai

3. Verify your program

Formally verify this program.