zkAPI
API Reference

ZkApiVault

Ethereum settlement contract

The user's wallet calls ZkApiVault directly on chain for deposits, mutual close, and escape-hatch withdrawals.

Deposit

FieldValue
Methoddeposit(bytes32 commitment, uint128 amount, uint256[32] siblings)
CallerUser's wallet (first calls token.approve(vault, amount))
EffectVerifies siblings + empty leaf against current root; updates root with new leaf; escrows amount of token; emits NoteDeposited(noteId, commitment, amount, expiryTs, newRoot)

Mutual close

FieldValue
MethodmutualClose(WithdrawalPublicInputs inputs, bytes proofEnvelope)
CallerUser's wallet
EffectVerifies proof via IZkApiProofAdapter; checks inputs.clear_sig_epoch / root match registered XMSS root; transfers final_balance → destination, deposit − final_balance → treasury; marks note Closed; emits MutualClose

Initiate escape-hatch withdrawal

FieldValue
MethodinitiateEscapeWithdrawal(WithdrawalPublicInputs inputs, bytes proofEnvelope)
CallerUser's wallet
EffectVerifies proof; zeroes leaf immediately; stores challengeDeadline = now + 24h; emits EscapeWithdrawalInitiated

Challenge a stale escape withdrawal

FieldValue
MethodchallengeEscapeWithdrawal(uint32 noteId, RequestPublicInputs inputs, bytes proofEnvelope)
CallerServer's wallet (during 24h window)
EffectVerifies the prior request proof; checks its nullifier matches the withdrawal nullifier; restores the leaf; cancels the pending withdrawal; emits EscapeWithdrawalChallenged

Finalize escape withdrawal

FieldValue
MethodfinalizeEscapeWithdrawal(uint32 noteId, address destination, uint128 finalBalance)
CallerAnyone (after deadline)
EffectRequires now > challengeDeadline; transfers finalBalance → destination, deposit − finalBalance → treasury; emits EscapeWithdrawalFinalized

Claim expired note (treasury sweep)

FieldValue
MethodclaimExpired(uint32 noteId, uint256[32] siblings)
CallerAnyone (funds go to treasury regardless)
EffectRequires now > expiry_ts; zeroes leaf; transfers full deposit to treasury; emits ExpiredClaimed

Rotate server's XMSS roots

FieldValue
MethodrotateServerRoots(uint32 epoch, bytes32 stateSigRoot, bytes32 clearSigRoot)
CallerContract owner (operator only)
EffectPublishes XMSS public roots for the new epoch, enabling withdrawal-proof verification against this epoch

On this page