CLI reference
Every leankey command and flag, with real output from a local validator.
leankey is the Lean Key command-line tool, version 0.1.0. It is written in TypeScript on packages/core and compiled with Bun into single-file binaries. The release build of the program (twokey.so), its program.json and proofs.json are embedded in it.
Install
Prebuilt binaries are on /cli with their sizes and sha256:
| File | Platform |
|---|---|
leankey-macos-arm64 | macOS, Apple silicon |
leankey-macos-x64 | macOS, Intel |
leankey-linux-x64 | Linux x86-64 |
From a source checkout, bun apps/cli/src/main.ts runs the same program (bun run cli from the repository root).
The output below was printed by the CLI on a local validator with the release build loaded. Absolute paths are shortened, and the 24 words are left out. Compute units depend on the intent and differ from run to run.
Global flags and environment
| Flag | Environment | Default | Meaning |
|---|---|---|---|
--network NAME | LEANKEY_NETWORK | mainnet | localnet, devnet or mainnet. |
--rpc URL | LEANKEY_RPC | http://127.0.0.1:8899, https://api.devnet.solana.com or https://api.mainnet-beta.solana.com | RPC endpoint. |
--program ID | LEANKEY_PROGRAM_ID | the network's id from packages/core | Program id. |
--payer FILE | the signing keypair | A keypair file that pays fees (and the rent of a recipient's new token account). | |
--priority N | none | Adds a compute-unit price of N micro-lamports per compute unit. | |
--skip-preflight | off | Sends without the simulation that follows signing and without the RPC's preflight. The placeholder check before signing still runs. | |
--json | off | Machine-readable output. Errors become a JSON object with an error field. | |
-h, --help | The command list. |
| Environment | Used by |
|---|---|
LEANKEY_PASSWORD | Every command that reads or writes a seed file, instead of the terminal prompt. Without a terminal and without this variable, the CLI stops with "no TTY to ask for the password: set LEANKEY_PASSWORD". |
LEANKEY_WORDS | keygen --import, instead of the prompt. |
LEANKEY_LOCALNET_DIR | localnet: where the ledger, keypairs and log live. Default ~/.leankey/localnet. |
LEANKEY_SOLANA_BIN | localnet: the directory with solana-test-validator. |
NO_COLOR | Turns off colors. |
Flags take their value as the next argument or after =: --network devnet or --network=devnet.
Exit status: 0 on success, 1 on any error, 2 when verify finds a mismatch.
Files
| File | Content |
|---|---|
pq.seed (or --out/--pq path) | The encrypted post-quantum seed: scrypt and AES-256-GCM, JSON, file mode 600. |
pq.seed.journal.json | The journal of signed intents for that seed: one entry per vault and key index with the intent bytes, the WOTS+ signature, the time, and once landed settled and the transaction signature. File mode 600. |
Keep the journal next to the seed file. It is what stops the CLI from signing two intents with one key. See Concepts.
keygen
leankey keygen [--out pq.seed] [--import] [--json] [--show-words]
Creates a new 32-byte seed, or with --import restores one from 24 words, asks for a password twice (8 characters or more) and writes the encrypted seed file. It refuses to overwrite an existing file. Without --import it prints the 24 words once; there is no command to show them again. --json --show-words puts the words in the JSON output.
leankey keygen --out ~/.leankey/localnet/pq.seed
wrote ~/.leankey/localnet/pq.seed (scrypt N=32768, AES-256-GCM, mode 600)
Your post-quantum seed (write these 24 words on paper; they are the only backup)
(the 24 words are printed here; write them on paper)
Anyone with these words and your wallet key can withdraw. Nobody with only one of them can.
The words are printed in four columns of six, numbered 1 to 24.
leankey keygen --import --out restored.seed
wrote /home/you/restored.seed (scrypt N=32768, AES-256-GCM, mode 600)
error: /home/you/pq.seed exists; refusing to overwrite a seed
open
leankey open --owner <keypair.json|PUBKEY> --pq pq.seed [--id N]
Opens vault number N of the owner (InitVault). Without --id, it takes the lowest number the owner does not use yet. The seed gives the hash of key #0 for the vault's address.
With a keypair file, the CLI signs and sends:
opened 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX (slot 29, vault #0, key #0, 4,461 CU)
With a public key instead (a hardware or browser wallet), it prints the unsigned transaction, base64, for that wallet to sign and send (shortened here):
vault #0 will be 2Z5rhHZ4A1gXSuiggRpkKpnqHVE84tLYP5bDJEWKiqR1
external owner: sign and send this transaction with HPSsKrQKoo9WBQTyLw7MbtnSvnWYqdc6YoiUW1vj7zmP (blockhash valid ~60 s):
AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIE83sEbUUUG1iiWDzG…
If the vault number is taken:
error: vault #0 of this owner is already open: 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX
status
leankey status <VAULT> [--pq pq.seed] [--limit N]
The vault's owner, number, key index, state, balances and tokens, and its history from the chain (--limit, default 10 transactions). With --pq, it also reads the journal and reports a pending intent for the current key.
vault 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX (localnet)
owner A5VRCLrrRLMqLCxzGHQoCtrtZjRRtxABVpMUjNtWbj52
id #0
key #2 pk_hash b73532a0b81c7559…
state open
balance 1.75152424 SOL (1.75 SOL withdrawable; 0.00152424 SOL rent-exempt minimum)
token 150 mint 4qzyknafQDHN5t8HeNNkEnqBMFzriK9KeTuLCnB8VjKP
pending key #2 signed an intent that has not landed; only it can be sent (leankey pending --send)
history
78 sent 100 of 4qzy… → BT1a… key #1→#2, 503,083 CU
75 sent 0.75 SOL → HPSs… key #0→#1, 526,950 CU
72 deposit 250 of 4qzy…, 21,123 CU
70 deposit 2.5 SOL, 150 CU
29 opened, 4,461 CU
For a token send, the arrow points to the destination token account, which is what the intent names.
vaults
leankey vaults <OWNER>
Every vault of an owner on the network, by number.
#0 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX key #6 0.00152424 SOL closed
#1 AwzhRZ9TqZ7CeXwGR5DSzUCpYsF8rgyi6sEGtfABywGY key #0 0.00152424 SOL
This lists every Lean Key vault whose stored owner is that address, including any that someone else opened with your owner key and their own seed. Add --pq pq.seed and each line is marked: your seed when the vault's current key hash comes from that seed, ANOTHER SEED: do not deposit when it does not. leankey deposit takes --pq too and then refuses a vault whose key is not yours. See Threat model.
deposit
leankey deposit <VAULT> <AMOUNT> [--mint MINT] --from <keypair.json> [--yes]
A plain transfer into the vault. The CLI first checks that the address is a Lean Key vault on this network and refuses a closed one. With --mint, it creates the vault's associated token account if needed and sends with TransferChecked; it refuses Token-2022 mints with a transfer hook, because they could not be withdrawn. On mainnet, a SOL deposit that would take the vault past 10 SOL needs --yes.
deposited 2.5 SOL (slot 70, vault balance 2.50152424 SOL)
deposited 250 (slot 72, vault token account Ef8L… holds 250)
error: this vault is closed; open a new one
send
leankey send <VAULT> <TO> <AMOUNT|max> [--mint MINT] --owner <keypair.json> --pq pq.seed
A withdrawal with both signatures. TO is a wallet address; for tokens the CLI uses its associated token account and creates it in the same transaction if it does not exist. max sends everything above the rent-exempt minimum (SOL) or the vault's whole balance of the mint. Amounts are decimal, in SOL or in the token's units.
The CLI runs the safe send order: preflight with a placeholder signature, local checks, signing under the journal rule, a simulation with the real signature, then sending.
sent 0.75 SOL to HPSsKrQKoo9WBQTyLw7MbtnSvnWYqdc6YoiUW1vj7zmP (slot 75, key #0 → #1, 526,950 CU)
sent 100 of 4qzy… to HPSsKrQKoo9WBQTyLw7MbtnSvnWYqdc6YoiUW1vj7zmP (slot 78, key #1 → #2, 503,083 CU)
sent 150 of 4qzy… to HPSsKrQKoo9WBQTyLw7MbtnSvnWYqdc6YoiUW1vj7zmP (slot 147, key #3 → #4, 568,645 CU)
With --json:
{
"signature": "5jD3rmpt46fYFB67vx9ZwRDjsPoxNz6EF3LZnaQjm2VqDQiCNTnatMmCn9zngDZoqpaXLjHycreHS7CDefjDxqjr",
"slot": 10,
"amount": "250000000",
"destination": "6z3aeTKfDhs7x5seKn5vDM2FS28SrVDsFf7cGV9DbcGs",
"keyFrom": "1",
"keyTo": "2",
"computeUnits": 567240
}
Refusals, none of which sends anything:
error: This vault's owner is A5VRCLrrRLMqLCxzGHQoCtrtZjRRtxABVpMUjNtWbj52, not HPSsKrQKoo9WBQTyLw7MbtnSvnWYqdc6YoiUW1vj7zmP.
error: Only 0 lamports are above the vault's rent-exempt minimum.
error: Key #2 of this vault already signed a different intent. Only that intent can be sent (Retry); signing another one with the same one-time key would weaken it.
see it: leankey pending 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX --owner … --pq pq.seed
A seed that is not the vault's passes the placeholder check, is used to sign, and is then refused in the simulation:
error: Signed, but the simulation failed: BadSignature (6005): The hash signature does not match the vault's current one-time key. Retry the same intent once the cause is fixed.
close-token
leankey close-token <VAULT> --mint MINT --to <ADDR> --owner <keypair.json> --pq pq.seed
Closes the vault's empty associated token account for the mint (CloseTokenAccount); its rent goes to --to. Withdraw the tokens first.
closed the vault's token account, rent to A5VRCLrrRLMqLCxzGHQoCtrtZjRRtxABVpMUjNtWbj52 (slot 150, key #4 → #5, 407,339 CU)
close
leankey close <VAULT> --to <ADDR> --owner <keypair.json> --pq pq.seed
CloseVault: everything above the rent-exempt minimum goes to --to, and the vault is marked closed. The address stays as a tombstone.
closed 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX (slot 152, key #5 → #6, swept 1.45 SOL, 526,949 CU); the address stays as a tombstone and can never be opened again
pending
leankey pending <VAULT> --owner <keypair.json> --pq pq.seed [--send]
Shows the intent the vault's current key has signed, if it has not landed. With --send, sends exactly that intent again in a new transaction.
key #2 signed: Withdraw SOL 300000000 → HPSsKrQKoo9WBQTyLw7MbtnSvnWYqdc6YoiUW1vj7zmP, 2026-12-02T22:48:53.884Z
send exactly this intent again with --send
sent the pending intent (slot 133, key #2 → #3, 567,240 CU)
no pending intent: key #3 has not signed anything
The amount is printed in base units (lamports here).
verify
leankey verify <VAULT|PROGRAM_ID>
For a program id: reads the program data account, prints the deploy slot and the upgrade authority, and compares the sha256 of the deployed bytes with the release build's. Exit status 2 on a mismatch. This works without a seed and without --program.
program KeyW6VkKqn3awBMcun9aLPKJuCP77BFM7KE66CyzCjE (mainnet)
loader BPF upgradeable loader, deployed at slot 476990156
authority 6MYxzskeNrvpDJLtuyYubAvNrDM7m7c7fLbZxy7PcvG9
on chain sha256 4e174b5a9bdd90ca5092b8db8bb4b0b158b722902a75d863ffc47ae684e69b1d (14688 B of 14688 B)
release sha256 4e174b5a9bdd90ca5092b8db8bb4b0b158b722902a75d863ffc47ae684e69b1d (program/release/program.json)
result the deployed program is byte-for-byte the release build
An immutable program prints authority none: the program is immutable. The mainnet deployment above has an upgrade authority.
For a vault: checks that it is owned by the network's Lean Key program and that its address is the derivation of ["vault", owner, vault_id] with its stored bump, then prints its state. Exit status 2 if either check fails.
vault 61USW8fjW4BsaeHsWwKiPE4KZrWgDEN5y5PT4bc1UsNX
program TwoKWxqD6kL6ow9bAEZ3Kir9hUFKbocX4LZR4j5R3W6 (Lean Key on localnet)
address PDA of ["vault", owner, #0] with bump 255
owner A5VRCLrrRLMqLCxzGHQoCtrtZjRRtxABVpMUjNtWbj52
key #6, 6 one-time keys used
state closed (tombstone), created at slot 29
balance 0.00152424 SOL, rent-exempt minimum 0.00152424 SOL
proofs
leankey proofs [--all] [--json]
The theorems from the embedded proofs.json, grouped, with file, line and the axioms Lean's kernel reports. Without --all it lists the 21 headline theorems; --all lists all 51. The first and last lines:
51 theorems checked by Lean's kernel (leanprover/lean4:v4.36.0, lean-svm a49cc65)
State machine
withdraw_requires_owner_signer Owner signature
program/Twokey/Proofs/Machine.lean:127 axioms: propext, Classical.choice, Quot.sound
withdraw_requires_valid_wots Hash signature
program/Twokey/Proofs/Machine.lean:139 axioms: propext, Classical.choice, Quot.sound
WOTS+ specification
wots_complete Completeness
program/Twokey/Proofs/Wots.lean:81 axioms: propext, Classical.choice, Quot.sound
verifySteps_eq The cost of verifying
program/Twokey/Proofs/Wots.lean:87 axioms: propext, Quot.sound
wots_no_domination No forgery by walking forward
program/Twokey/Proofs/Wots.lean:152 axioms: propext, Classical.choice, Quot.sound
no sorry; nothing rests on more than propext, Quot.sound, Classical.choice. Program sha256 4e174b5a9bdd90ca5092b8db8bb4b0b158b722902a75d863ffc47ae684e69b1d
"The program's source" is the SolanaM code lean-svm compiles into the .so, under lean-svm's model of the runtime; the compiler itself is trusted. See Trust boundaries.
localnet
leankey localnet [--detach] [--reset] [--stop]
Starts solana-test-validator (Agave 4.x or newer is required for sBPF v3) on http://127.0.0.1:8899 with the embedded release build loaded as an upgradeable program at TwoKWxqD6kL6ow9bAEZ3Kir9hUFKbocX4LZR4j5R3W6, creates wallet.json and authority.json in ~/.leankey/localnet (or LEANKEY_LOCALNET_DIR), and airdrops 100 SOL to the wallet. It refuses to start if a validator already answers on that port.
| Flag | Effect |
|---|---|
--detach | Keep the validator running in the background and return. |
--reset | Start from an empty ledger. A missing ledger is always reset. |
--stop | Stop a validator this command started. |
Without --detach, Ctrl-C stops the validator.
localnet ready http://127.0.0.1:8899 (solana-test-validator)
program TwoKWxqD6kL6ow9bAEZ3Kir9hUFKbocX4LZR4j5R3W6 (release build, upgradeable, authority G1ojQpFdRoKKojBijmUd3ioVgJSEcR4JvNxAqEbp4ao8)
wallet 5wykdpPiTveo3J9dGL8FXjUG7er5x6bQeURHUy21Ysfo 100 SOL ~/.leankey/localnet/wallet.json
leankey keygen --out pq.seed
leankey open --owner ~/.leankey/localnet/wallet.json --pq pq.seed --network localnet
leankey deposit <VAULT> 2 --from ~/.leankey/localnet/wallet.json --network localnet
leankey send <VAULT> <TO> 0.5 --owner ~/.leankey/localnet/wallet.json --pq pq.seed --network localnet
leankey verify TwoKWxqD6kL6ow9bAEZ3Kir9hUFKbocX4LZR4j5R3W6 --network localnet
running in the background (pid 69691); stop it with: leankey localnet --stop
help, version
leankey help (or no command, or -h) prints the command list. leankey version prints 0.1.0.
JSON mode
Every command accepts --json. Successful commands print one JSON object. Values that are 64-bit integers in the program (amounts, lamports, key indexes) are printed as decimal strings, and addresses as base58 strings. Failures print a JSON object with a single error field and exit with status 1. The local-validator test (scripts/localnet/e2e.ts) drives the CLI entirely through --json.