Prerequisites
- Node 22 or later.
- A mainnet RPC URL. Any provider works; the public endpoint is rate-limited and may fail some calls.
- A Solana keypair file with at least 2 USDC and 0.01 SOL. Cloak runs on mainnet only, so use a wallet you can afford to experiment with.
Step 1: Open the account
Put the setup in one module that every step imports:setup.ts
step1.ts
cloak_ address. The same key always
opens the same account. Nothing was sent to the chain.
Step 2: Quote before moving money
step2.ts
1 arrives.
Step 3: Shield 2 USDC
step3.ts
Step 4: Send 1 USDC privately
Send to your owncloak_ address here, or to a friend’s. Run each step with npx tsx stepN.ts.
step4.ts
Step 5: Withdraw 1 USDC
step5.ts
What you built
Next steps
Next.js application
The same flow in a browser, with a connected wallet.
Wallet integrations
Phantom, Privy, hardware and smart wallets.
Notes and balances
Where the notes live and what to back up.
Error codes
What each failure means and whether to retry.