Spring
WhitepaperGitHubLaunch app

Docs / Build

API reference

Every instruction of the Spring program, its arguments, its accounts and the event it emits.

deposit

deposit(value: u64, precommitment: [u8; 32])

AccountSignerWritableNotes
depositoryesyesPays value
poolyesPDA ["pool"]
system_program

Requires value >= min_deposit and a canonical precommitment. Emits Deposited { depositor, nonce, label, value, fee, precommitment, commitment, leaf_index, root }, where value is the note value after the fee.

withdraw

withdraw(nullifier_hash: [u8; 32], args: WithdrawArgs)

FieldTypeMeaning
proof[u8; 256]Groth16 proof: -A, B, C big-endian
new_commitment[u8; 32]Change note
withdrawn_valueu64Lamports leaving the pool
state_root, state_depth[u8; 32], u8One of the last 64 state roots
asp_root, asp_depth[u8; 32], u8The provider's current root, or its previous one within 150 slots
relayer_feeu64Paid to fee_recipient out of withdrawn_value
AccountSignerWritableNotes
processoryesyesSubmits and pays the nullifier rent; bound into the proof
poolyesPDA ["pool"]
providerPDA ["asp", authority]
nullifieryesPDA ["nullifier", nullifier_hash], created here
recipientyesReceives withdrawn_value - relayer_fee
fee_recipientyesReceives relayer_fee
system_program

Emits Withdrawn { processor, recipient, fee_recipient, value, relayer_fee, provider, asp_root, nullifier_hash, new_commitment, leaf_index, root }.

ragequit

ragequit(nullifier_hash: [u8; 32], args: RagequitArgs) with proof, new_commitment, withdrawn_value, state_root, state_depth and the deposit's nonce.

AccountSignerWritableNotes
depositoryesyesMust be the key that made the deposit; receives the funds
poolyesPDA ["pool"]
nullifieryesPDA ["nullifier", nullifier_hash]
system_program

The program recomputes the label from the signer and the nonce and uses it as a one-leaf set root. Emits Ragequit { depositor, label, value, nullifier_hash, new_commitment, leaf_index, root }.

transfer_note

transfer_note(nullifier_hash: [u8; 32], args: TransferArgs)

A private payment inside the SOL pool. TransferArgs is WithdrawArgs plus the recipient's receive code:

FieldTypeMeaning
withdrawn_valueu64Taken out of the sender's note: the recipient's amount plus relayer_fee
relayer_feeu64Must be below withdrawn_value; the only amount that leaves the pool
recipient_ownerPubkeyThe recipient's label is built from this key, so it alone can ragequit the new note
recipient_precommitment[u8; 32]Poseidon(nullifier, secret) chosen by the recipient

The proof's context is H(5, scope, processor, recipient_owner, fee_recipient, relayer_fee, recipient_precommitment), so a relayer cannot redirect the note or raise its fee. Accounts: processor (signer), pool, provider, nullifier (created), fee_recipient, system_program. Appends two leaves (the change note, then the recipient's note) and emits Transferred { processor, recipient_owner, fee_recipient, nonce, label, value, relayer_fee, provider, asp_root, nullifier_hash, change_commitment, change_leaf_index, change_root, precommitment, commitment, leaf_index, root }.

Token pools

One pool per mint at PDA ["pool", mint], its tokens in ["vault", pool]. Same notes, labels, sets and proofs as the SOL pool; each pool has its own scope, so a proof never spends in another pool.

InstructionWhoNotes
initialize_token_pool(owner, fee_bps, min_deposit)upgrade authoritySPL Token or Token-2022 mint; the whole fee goes to the treasury
deposit_token(value, precommitment)depositorRefused with TransferShortfall if the vault receives less than value (transfer-fee mints)
withdraw_token(nullifier_hash, WithdrawArgs)anyone, usually a relayerPays recipient_tokens and fee_recipient_tokens, both token accounts owned by the addresses the proof binds
ragequit_token(nullifier_hash, RagequitArgs)original depositorBack to the depositor's token account
transfer_note_token(nullifier_hash, TransferArgs)anyone, usually a relayerThe relayer fee is paid in the pool's token
withdraw_token_treasury(amount)pool ownerTreasury bucket only
close_token_pool()pool ownerOnly once no note and no treasury is owed; returns the pool's and the vault's rent, and any tokens sent to the vault by hand go to a sweep account

Set providers

InstructionSignerEffectEvent
register_provider(authority)pool ownerCreates ["asp", authority]ProviderRegistered
publish_root(root, set_hash)provider authorityCurrent root moves to previous, new root recorded with its slotRootPublished { provider, root, set_hash, index, slot }
retire_provider()pool ownerOne-way: its roots stop workingProviderRetired

Owner

InstructionEffect
initialize(owner, fee_bps, burn_share_bps, min_deposit)Creates the pool; only the program's upgrade authority can call it; fee_bps <= 100
withdraw_treasury(lamports)Moves lamports out of the treasury bucket only; note balances are out of reach