Start
First private swap
This page takes you from a public wallet to a swap on Jupiter that your wallet is not part of. You enter with USDC, run jupiter.swap, and end with SOL in your private balance. It takes a few minutes in the app, or about ten lines with the SDK.
What you need
- A Solana wallet holding the asset you want to swap. The examples use USDC.
- A little SOL in that wallet for the network fee of the one transaction it signs.
Your wallet signs twice in total: one message to unlock, and one transaction to enter. The swap itself is submitted by a relayer.
The steps
Connect and unlock
Open Balance and press Connect wallet. Then press Unlock. Your wallet signs one message, and the keys to your notes are made from it in the browser.
Enter
Press Enter. Leave From on Your wallet, pick USDC under Asset, and type an amount. The panel on the right shows what will go into your private balance and what the chain will show. Press Enter and approve the transaction in your wallet.
The screen follows it: Build the transaction, Sign in your wallet, Submitted, In your private balance. When it reads You are in, the USDC is a note in your balance.
Open the swap
Back on Balance, under Run a hook, press Swap. It opens the run screen for
jupiter.swap.Read the quote
Pick USDC as the asset in, type an amount, and pick SOL as the asset out. Slippage starts at 0.5%.
The quote shows what you receive into your private balance, with the expected out, the minimum out, the run fee, the relayer's fee and the route. Under What the chain will show it lists the hook, the address that submits the run, and that your wallet is not in it.
Run
Press Run. Your wallet is not asked for anything. The screen follows three stages: Making the proofs, Relayed, Confirmed.
At Done, the SOL is a new note. Balance shows it, and Activity lists the enter and the run with their transactions.
Install the SDK and the circuits it proves with.
npm i @pook/sdk @pook/circuitsThen enter and run. signer is your wallet: Call a hook from your app shows its three members.
import { createPook } from '@pook/sdk'
import { loadCircuits } from '@pook/circuits'
const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
const SOL = 'So11111111111111111111111111111111111111112'
const pook = createPook({ apiUrl: 'https://api.pook.codes', wasm: await loadCircuits(), signer })
// One message signature. Every key is derived from it on this device.
await pook.unlock()
// 20 USDC, in base units. The wallet signs this one transaction.
await pook.enter({ mint: USDC, amount: '20000000' })
// 10 USDC to SOL. A relayer submits it; the wallet signs nothing.
const run = await pook.run('jupiter.swap', {
in: USDC,
out: SOL,
amount: '10000000',
slippageBps: 100,
})
console.log(run.relay.status, run.signature)
const { assets } = await pook.balance()run.relay.status is confirmed when the swap has landed, and run.signature is its transaction. assets lists each asset you hold with its amount in base units: the USDC that is left, and the SOL the swap returned.
What just happened
The swap was one transaction. Inside it the Pook program verified your proof, spent your USDC note, called Jupiter with exactly the route the quote resolved, checked that at least the minimum out came back, took the fees and deposited the rest as a new note that only you can spend. Had any of those steps failed, the whole transaction would have failed and your USDC note would be as it was.
Open the run in the run feed to see what the chain recorded: the hook, the amounts, the relayer. Your wallet appears in the enter, and nowhere after it.