docs
Spec for a second client
Everything needed to hand accounts over, sign and verify without this site: addresses, byte layouts, the signed message, the instructions, the errors and the money. The source repository goes public at launch; until then this page is the reference.
Addresses
- Program:
9j235y1rrRrxuMAxVN8Dm4aEskuE6ATCg64vQEgxdJ3y(Anchor 1.2, upgradeable; not deployed until launch). - Config: PDA
["config"]=GH9yeXamcsByhWZu6JG6Bki74V654itD6dHgf6efwcow. - Slip: PDA
["slip", id]with id = keccak("qslip/id" ‖ the first key, 41 bytes). It becomes the withdraw authority of the accounts handed to it; a rekey keeps the address. - Scratch account: PDA
["stage", slip, payer], holds the first 640 bytes of a signature between the two transactions.
The key
Target-sum Winternitz one-time keys (w = 4, 36 chains of 16 positions, 23-byte elements, every digit vector sums to 297, 21-byte salt) under a 256-leaf Merkle tree, Keccak-256 throughout: the parameters and tweaks of blueshift-gg/solana-winternitz (DKKW25). Public key = Merkle root (23 bytes) ‖ public parameter P (18 bytes) = 41 bytes. Signature = leaf (u32 big-endian) ‖ salt ‖ 36 elements ‖ 8 path nodes = 1,037 bytes. Leaves 0 to 247 sign requests; 248 to 255 only sign a rekey.
Our derivation (any other works if it is kept secret): seed = BIP-39 seed of the 24 words (empty passphrase); master = HMAC-SHA512(key "qslip slip", seed); tree g = HMAC-SHA512(key master[0..32], "tree" ‖ u32be g); P = keccak("qslip/param" ‖ tree g)[0..18]; chain start (leaf l, chain i) = keccak("qslip/start" ‖ tree g[0..32] ‖ u32be l ‖ u8 i)[0..23].
The signed message
digest = keccak256( "qslip/v1" ‖ program id ‖ slip ‖ generation u32le ‖ kind u8
‖ target[32] ‖ aux[32] ‖ destination[32] ‖ expiry u64le ‖ new_key[41] )
kind 1 withdraw target = the stake or vote account aux = amount u64le, then zeros destination = gets the lamports
kind 2 release target = the account destination = the new withdraw authority
kind 3 new staker target = the stake account destination = the new staker
kind 5 rekey new_key = the next tree's key; target, aux, destination zero
unused fields are zero bytes; expiry at most 1,500 slots ahead
Instructions
Anchor discriminators (first 8 bytes of sha256("global:<name>")), then Borsh arguments.
open e4dc9b47c7bd3c2d id[32], key[41]
payer(w,s) config(w) slip(w) system
enroll_stake 535a70d9d4a9f5cf (no arguments)
payer(w,s) authority(s) config(w) slip(w) stake(w) clock stake_program treasury(w) system [holder token account]
enroll_vote 56a2fe9346f33fa0 (no arguments)
payer(w,s) authority(s) config(w) slip(w) vote(w) clock vote_program treasury(w) system [holder]
stage 6e2e30a48afd3c2e head: vec<u8> (640)
payer(w,s) slip stage(w) system
withdraw b712469c946da122 amount u64, expiry u64, tail: vec<u8> (397)
payer(w,s) config(w) slip(w) stage(w) target(w) destination(w) clock stake_history stake_or_vote_program treasury(w) system [holder]
release fdf90fce1c7fc1f1 expiry u64, tail
payer(w,s) config(w) slip(w) stage(w) target(w) new_authority(s) clock stake_or_vote_program
set_staker 95cb721c508a1183 expiry u64, tail
payer(w,s) slip(w) stage(w) stake(w) new_staker clock stake_program
rekey dc788d53d26ad890 new_key[41], expiry u64, tail
payer(w,s) slip(w) stage(w)
drop_stage 80bbf1451cc3faff (the payer any time; anyone after 9,000 slots)
caller(s) stage(w) rent_to(w)
admin: init dc3bcfec6cfa2f64, set_params 1beab2349302bb8d, set_paused 5b3c7dc0b0e1a6da (new Slips and enrolments only),
set_root b7310acea8b78343, close_config 9109489d5f7d3d55 (only while paused)
One approval fits open and 14 enroll_stake instructions in a legacy transaction with the priority-fee pair (measured: 1,226 of 1,232 bytes), 13 with a holder's token account on each.
Accounts
Slip (176 bytes): disc[8] id[32] key[41] generation u32 used[32] spent u16 opener[32] opened_slot u64
stake_accounts u32 vote_accounts u32 withdrawals u32 ops u32 bump u8
Config (182): disc[8] admin[32] treasury[32] mint[32] stake_fee u64 vote_fee u64 withdraw_fee u64 holder_min u64 paused u8
slips u32 stake_enrolled u32 vote_enrolled u32 released u32 withdrawals u32
guarded_lamports u64 withdrawn_lamports u64 fees u64 bump u8
Stage (720): disc[8] slip[32] payer[32] slot u64 head[640]
Native layouts read: stake (StakeStateV2) staker 12..44, withdrawer 44..76, lockup 76..124, delegation stake 156..164,
deactivation epoch 172..180; vote: identity 4..36, withdraw authority 36..68 (every version in use)
Rules
- Once a signature verifies its leaf is spent in that transaction. A request that cannot run is recorded void (event
Voided, reasons: 1 expired, 2 expiry too far ahead, 3 the account is not under this Slip, 4 more than the account can give now, 5 the destination cannot take it, 6 same key or same staker, 7 a lockup is in force) and moves nothing. - What a withdrawal may take: from a stake account that was never delegated or was deactivated in an earlier epoch, all of it or anything that leaves the rent reserve; from a delegated one, only what sits above the delegated stake and the reserve; from a vote account, anything that leaves its rent.
- A refused request (bad signature, used or reserved leaf, wrong scratch account, stake rewards being paid) changes nothing and spends nothing.
- The staker is never touched by a hand-over. The withdraw authority also decides a vote account's commission and identity: those need a release first.
Money
A fee per account handed over and per signed withdrawal, paid by the fee payer to the treasury inside the instruction (the values on chain in the Config; ceilings 0.2 SOL a stake account, 1 SOL a vote account, 0.05 SOL a withdrawal in the code). A payer that passes its own token account holding at least holder_min of $QSLIP pays none. Release, new staker, rekey: no fee. The program never holds the accounts' SOL. A Slip's rent is about 0.0016 SOL (176 bytes); a scratch account's (720 bytes, 0.0043 SOL) returns to its payer in the same request.