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])
| Account | Signer | Writable | Notes |
|---|---|---|---|
| depositor | yes | yes | Pays value |
| pool | yes | PDA ["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)
| Field | Type | Meaning |
|---|---|---|
| proof | [u8; 256] | Groth16 proof: -A, B, C big-endian |
| new_commitment | [u8; 32] | Change note |
| withdrawn_value | u64 | Lamports leaving the pool |
| state_root, state_depth | [u8; 32], u8 | One of the last 64 state roots |
| asp_root, asp_depth | [u8; 32], u8 | The provider's current root, or its previous one within 150 slots |
| relayer_fee | u64 | Paid to fee_recipient out of withdrawn_value |
| Account | Signer | Writable | Notes |
|---|---|---|---|
| processor | yes | yes | Submits and pays the nullifier rent; bound into the proof |
| pool | yes | PDA ["pool"] | |
| provider | PDA ["asp", authority] | ||
| nullifier | yes | PDA ["nullifier", nullifier_hash], created here | |
| recipient | yes | Receives withdrawn_value - relayer_fee | |
| fee_recipient | yes | Receives 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.
| Account | Signer | Writable | Notes |
|---|---|---|---|
| depositor | yes | yes | Must be the key that made the deposit; receives the funds |
| pool | yes | PDA ["pool"] | |
| nullifier | yes | PDA ["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:
| Field | Type | Meaning |
|---|---|---|
| withdrawn_value | u64 | Taken out of the sender's note: the recipient's amount plus relayer_fee |
| relayer_fee | u64 | Must be below withdrawn_value; the only amount that leaves the pool |
| recipient_owner | Pubkey | The 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.
| Instruction | Who | Notes |
|---|---|---|
initialize_token_pool(owner, fee_bps, min_deposit) | upgrade authority | SPL Token or Token-2022 mint; the whole fee goes to the treasury |
deposit_token(value, precommitment) | depositor | Refused with TransferShortfall if the vault receives less than value (transfer-fee mints) |
withdraw_token(nullifier_hash, WithdrawArgs) | anyone, usually a relayer | Pays recipient_tokens and fee_recipient_tokens, both token accounts owned by the addresses the proof binds |
ragequit_token(nullifier_hash, RagequitArgs) | original depositor | Back to the depositor's token account |
transfer_note_token(nullifier_hash, TransferArgs) | anyone, usually a relayer | The relayer fee is paid in the pool's token |
withdraw_token_treasury(amount) | pool owner | Treasury bucket only |
close_token_pool() | pool owner | Only 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
| Instruction | Signer | Effect | Event |
|---|---|---|---|
register_provider(authority) | pool owner | Creates ["asp", authority] | ProviderRegistered |
publish_root(root, set_hash) | provider authority | Current root moves to previous, new root recorded with its slot | RootPublished { provider, root, set_hash, index, slot } |
retire_provider() | pool owner | One-way: its roots stop working | ProviderRetired |
Owner
| Instruction | Effect |
|---|---|
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 |