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.
If your app stack is built around @solana/kit, you can still use Cloak SDK today.
Current state:
- Use Kit for RPC reads, subscriptions, and signer architecture.
- Use a thin
@solana/web3.js bridge for Cloak transaction calls (transact, partialWithdraw, swapWithChange, etc.).
Install
npm install @cloak.dev/sdk @solana/web3.js @solana/kit
Minimal bridge pattern
import {
CLOAK_PROGRAM_ID,
createUtxo,
createZeroUtxo,
generateUtxoKeypair,
partialWithdraw,
transact,
} from "@cloak.dev/sdk";
import { address, createSolanaRpc } from "@solana/kit";
import { Connection, Keypair } from "@solana/web3.js";
const rpcUrl = process.env.SOLANA_RPC_URL!;
const programId = CLOAK_PROGRAM_ID;
// Kit client for read paths.
const kitRpc = createSolanaRpc(rpcUrl);
// web3 bridge for Cloak transaction paths.
const connection = new Connection(rpcUrl, "confirmed");
const signer = Keypair.fromSecretKey(/* Uint8Array secret key */);
const { value: before } = await kitRpc
.getBalance(address(signer.publicKey.toBase58()))
.send();
const owner = await generateUtxoKeypair();
const output = await createUtxo(20_000_000n, owner);
const deposit = await transact(
{
inputUtxos: [await createZeroUtxo()],
outputUtxos: [output],
externalAmount: 20_000_000n,
depositor: signer.publicKey,
},
{
connection,
programId,
depositorKeypair: signer,
},
);
await partialWithdraw(
deposit.outputUtxos,
Keypair.generate().publicKey,
5_000_000n,
{
connection,
programId,
depositorKeypair: signer,
cachedMerkleTree: deposit.merkleTree,
},
);
const { value: after } = await kitRpc
.getBalance(address(signer.publicKey.toBase58()))
.send();
console.log(before.toString(), after.toString());
Use the concise snippets in Code Examples, then adapt them to your Kit app runtime.