DocsProgram reference

Program reference

The program is written in Rust with Pinocchio, builds as SBPFv3 and has no Anchor IDL. The TypeScript SDK is the reference client and is cross-tested against the program.

Deployment#

Cluster Solana devnet only
Program id 21pepQ5oBTgwnZNvqev94wXyywqMqiox8kQU2oBKfrRn
ProgramData AYtuzBYg9vc1pwzYBScF6Xt7sc85giVFiyT1FhhpggW
Upgrade authority 5MtrFZJPv4chkibZ9rPjAiPAG3oFfnrU6ZaxwFzDvy2m (Ed25519; see Security model)
Binary SBPFv3, 37,112 bytes
SHA-256 36f3d85eb56ab37ecb86a633fb250df09dbcd2c41157942f27c6f5478ec7a7a1
Audit not audited

Vault account#

PDA ["vault", vault_hash] with the canonical bump, owned by the program, 68 bytes:

Offset Size Field
0 1 discriminator Q (0x51)
1 1 layout version, 1
2 1 status: 1 Open, 2 Rolled, 3 Closed
3 1 bump
4 32 vault hash (WOTS root)
36 32 destination: next vault (Rolled) or recipient (Closed); zero while Open

The vault's lamports are its SOL balance. Its tokens are held in canonical associated token accounts ATA(vault, mint) of the classic SPL Token program.

Instructions#

The first data byte selects the instruction. All amounts are u64 little-endian. s = signer, w = writable.

# Instruction Data after the tag Accounts
0 OpenVault vault_hash[32] (non-zero) payer (s, w), vault (w), system program
1 DepositSol lamports[8] (> 0) depositor (s, w), vault (w), system program. Open vaults only.
2 DepositToken amount[8] (> 0) depositor (s), vault, source token account (w), vault ATA (w), mint, token program. Open vaults only, canonical ATA only.
3 Spend action[1] amount[8] next_hash[32] signature[624] see Spend accounts
4 SweepSol – spent vault (w), recorded destination (w)
5 SweepToken – payer (s, w), spent vault, vault token account (w), recorded destination, destination ATA (w), mint, system program, token program, ATA program

Spend instruction data is 666 bytes: tag, action, amount, next hash and the 624-byte WOTS signature. For Close, next_hash is 32 zero bytes. The signed message is described on the Cryptography page.

Spend accounts#

Core accounts, in order:

# Account
0 payer s, w; pays fees and the rent of new accounts
1 vault w
2 recipient w; may not be the vault or the next vault
3 next vault w; WithdrawSol and WithdrawToken only; must be the canonical PDA of next_hash, created if missing, and Open
– system program

If the spend binds a mint, a token tail follows:

Action Token tail
WithdrawSol mint, vault ATA, next-vault ATA, token program, ATA program
WithdrawToken mint, vault ATA, recipient ATA, next-vault ATA, token program, ATA program
Close mint, vault ATA, recipient ATA, token program, ATA program

Destination token accounts are created idempotently through the ATA program, which also checks their derivation. The vault's ATA for the bound mint is emptied and closed in every case.

Errors#

The program returns ProgramError::Custom(code):

Code Hex Name Meaning
1 0x1 VaultNotOpen the vault is Rolled or Closed (spend, deposit)
2 0x2 InvalidSignature the WOTS signature does not recover the vault hash
3 0x3 InvalidVaultAccount not a QVAULT vault account (owner, size or layout)
4 0x4 NextVaultMismatch the next-vault account is not the PDA of next_hash
5 0x5 InvalidRecipient the recipient is the vault itself or the next vault
6 0x6 InsufficientFunds the amount exceeds the balance, or there is nothing to sweep
7 0x7 InvalidMint a missing or invalid mint (WithdrawToken needs one)
8 0x8 InvalidTokenAccount a non-canonical or mismatched token account
9 0x9 InvalidProgram a wrong system, token or ATA program id (Token-2022 is rejected)
10 0xa InvalidDestination a sweep destination differs from the one recorded at spend time
11 0xb VaultNotSpent a sweep on a vault that is still Open
12 0xc InvalidNextHash zero, or equal to this vault's hash, for a withdrawal; non-zero for Close
13 0xd VaultAlreadyExists OpenVault on an existing vault
14 0xe InvalidAction an unknown spend action
15 0xf NextVaultNotOpen the next vault exists but is already spent
16 0x10 InvalidAmount a deposit of 0
17 0x11 MissingSigner a required signer did not sign
18 0x12 VaultAddressMismatch the vault account is not the PDA of the given hash

Compute and size#

Measured on devnet on 6 Dec 2026 with legacy transactions, one fee-payer signature and the SDK's SetComputeUnitLimit instruction:

Action Compute units Verify steps Transaction bytes (limit 1,232)
Open vault + deposit SOL + deposit token 20,913 – 472
WithdrawSol, one mint rolls along 460,205 3,315 1,174
WithdrawToken 583,730 4,080 1,207
Close, with one mint 451,140 3,315 1,141
WithdrawSol, SOL only – – 1,009
Close, SOL only – – 976
  • Cost model: about 131 compute units per verifier hash step, plus a fixed part of about 5.6k for a SOL-only spend, which includes PDA derivation and the next-vault creation. A token leg adds the token and ATA program calls.
  • Range: verify steps run from 0 to 6,630. The bound at the theoretical maximum is 874,120 compute units, under the 1.4M limit.
  • Compute limit set by the SDK: ceil((steps × 131 + fixed) × 1.15), with fixed = 12,000 for SOL-only spends and 90,000 when a mint is bound.
  • Size headroom: no address lookup table is needed. A SetComputeUnitPrice instruction (+12 bytes) still fits the largest transaction; a memo does not.

Devnet rent at measurement time: a vault account costs 504,700 lamports and a token account 754,475 lamports.

Verify the deployed binary#

The build is reproducible with the pinned toolchain. Devnet accepts only SBPFv3 programs, which need platform tools v1.54 or later.

# 1. Build from source (prints the SHA-256 of target/deploy/qvault.so)
programs/build.sh
#   = cargo build-sbf --manifest-path programs/qvault/Cargo.toml \
#       --arch v3 --tools-version v1.54
#     shasum -a 256 target/deploy/qvault.so

# 2. Dump what is deployed on devnet and hash it
solana program dump -u devnet \
  21pepQ5oBTgwnZNvqev94wXyywqMqiox8kQU2oBKfrRn onchain.so
shasum -a 256 onchain.so

# 3. Both must print
# 36f3d85eb56ab37ecb86a633fb250df09dbcd2c41157942f27c6f5478ec7a7a1

Use a Solana CLI that can parse SBPFv3 ELF files (Agave 4.4 or later); older CLIs fail with invalid file header. The repository is private for now, so step 1 is available to reviewers until the source is published.