Skip to main content
This page tracks the current exports in sdk/src/index.ts.

Main client: CloakSDK

Constructor

new CloakSDK({
  keypairBytes?: Uint8Array;
  wallet?: WalletAdapter;
  network?: "localnet" | "devnet" | "mainnet" | "testnet";
  cloakKeys?: CloakKeyPair;
  storage?: StorageAdapter;
  programId?: PublicKey;
  relayUrl?: string;
  debug?: boolean;
})
At least one signer path is required: keypairBytes or wallet.

Core methods

sdk.deposit(connection, amountOrNote, options?) => Promise<DepositResult>
sdk.withdraw(connection, note, recipient, options?) => Promise<TransferResult>
sdk.send(connection, note, recipients, options?) => Promise<TransferResult>
sdk.swap(connection, note, recipient, options) => Promise<SwapResult>
Also available:
sdk.privateTransfer(connection, note, recipients, options?)
sdk.generateNote(amountLamports, useWalletKeys?)
sdk.getMerkleProof(connection, leafIndex)
sdk.getCurrentRoot(connection)
sdk.getTransactionStatus(requestId)
Storage/key helpers on the class:
sdk.loadNotes()
sdk.saveNote(note)
sdk.findNote(commitment)
sdk.importWalletKeys(keysJson)
sdk.exportWalletKeys()
sdk.getConfig()

Note API types

type DepositResult = {
  note: CloakNote;
  signature: string;
  leafIndex: number;
  root: string;
};

type TransferResult = {
  signature: string;
  outputs: Array<{ recipient: string; amount: number }>;
  nullifier: string;
  root: string;
};

UTXO API

Exports from core/utxo.ts and core/transact.ts:
transact(params, options)
transfer(inputUtxos, recipientPubkey, amount, options)
partialWithdraw(inputUtxos, recipient, withdrawAmount, options)
fullWithdraw(inputUtxos, recipient, options)
swapUtxo(params, options)
swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount, options, recipientWallet?)
UTXO primitives:
generateUtxoKeypair()
createUtxo(amount, keypair, mint?)
createZeroUtxo(mint?)
computeUtxoCommitment(utxo)
computeUtxoNullifier(utxo)
Full flow guide: UTXO Transactions

Relay and proof utilities

new RelayService(baseUrl)
relay.submitWithdraw(...)
relay.submitSwap(...)
relay.getStatus(requestId)
relay.resumeWithdraw(requestId)

computeProofFromChain(connection, merkleTreePDA, leafIndex)
readMerkleTreeState(connection, merkleTreePDA)
buildMerkleTreeFromRelay(relayUrl)
Notes:
  • UTXO transact/swap flows submit 256-byte proofs and 264-byte public inputs.
  • RelayService.submitSwap currently uses legacy /withdraw route, while UTXO swap helpers use /transact_swap.

Fee constants

FIXED_FEE_LAMPORTS      // 5_000_000
VARIABLE_FEE_NUMERATOR  // 3
VARIABLE_FEE_DENOMINATOR// 1000
MIN_DEPOSIT_LAMPORTS    // 10_000_000
VARIABLE_FEE_RATE       // 0.003

calculateFee(amount: number)
calculateFeeBigint(amount: bigint)
getDistributableAmount(amount: number)

Error utilities

CloakError
ShieldPoolErrors
RootNotFoundError
isRootNotFoundError(error)
parseError(error)
parseTransactionError(error)
Detailed usage: Error Handling

Versioned exports

VERSION            // "2.0.0"
CLOAK_PROGRAM_ID   // mainnet program constant

Protocol and service docs