The UTXO API is the current production path for SDK-based app integrations.Documentation Index
Fetch the complete documentation index at: https://docs.cloak.ag/llms.txt
Use this file to discover all available pages before exploring further.
Core APIs
transact(params, options)transfer(...)partialWithdraw(...)fullWithdraw(...)swapUtxo(...)swapWithChange(...)
@cloak.dev/sdk.
Transaction semantics
externalAmount rules:
> 0: public deposit into the pool< 0: public withdrawal from the pool0: fully shielded transfer
264-byte public inputs and submits the resulting on-chain transaction.
Fees
- SOL withdraw/swap:
gross = abs(externalAmount)fee = 5_000_000 + floor(gross * 3 / 1000)net = gross - fee
- Deposits have no protocol fee but still must satisfy min deposit (
10_000_000lamports)
- SOL:
calculateSolFeeLamports,calculateSolNetAmountLamports
Create UTXOs
Deposit example (transact)
Withdraw and transfer helpers
partialWithdraw/fullWithdraw use negative externalAmount semantics.
Swap example
swapWithChange sends a TransactSwap payload (proof + 264-byte public inputs + swap params).
Viewing-key registration requirements
- Default behavior enforces viewing-key registration before protocol txs.
TransactOptions.enforceViewingKeyRegistrationdefaults totrue.- Registration signs the fixed sign-in message and submits the registration record.
Risk-oracle deposits
When deposits require Range/Switchboard validation, include:riskOracleQueueriskQuoteUrl(orgetRiskQuoteInstruction)
addressLookupTableAccounts.
Operational notes
- Amounts use
bigintin the UTXO API. - Proof retries are built in for stale roots (
0x1001). - SDK-side Merkle reconstruction is preferred for older indices.
- Optional
cachedMerkleTreehelps sequential txs avoid extra rebuild/fetch. - Optional
useUniqueNullifiershelps repeated development runs avoid nullifier collisions.
Troubleshooting
Invalid public inputs size: the protocol expects264bytes, not232.RootNotFound/0x1001: regenerate proof with fresh root (SDK retry usually handles this).0x1020in local repeated runs: setCLOAK_UNIQUE_NULLIFIERS=1.viewing key not found: re-run a transaction with registration enabled, then rescan history.
Next
- Protocol behavior: Shield Pool Program
- Runtime lifecycle: Transaction Flows
- Full SDK exports: API Reference