Docs · Guides
Deposit and withdraw
Move an asset from a public wallet into Mesa and back out, in the app or from code, with what each step shows on the chain.
Funds reach Mesa in two steps and leave in two. Between your public wallet and Mesa sits your Rings private balance, the balance Solana Privacy Rings keeps for your wallet.
| Step | Moves | Signed by | The chain shows |
|---|---|---|---|
| Wallet to Rings | Public balance to Rings private balance | Your wallet | Your address, the asset and the amount |
| Rings to Mesa | Rings private balance to a Mesa balance note | Your wallet | Your address. Asset and amount are encrypted. |
| Mesa to Rings | Mesa balance to Rings private balance | Nobody. It is proved and relayed. | The receiving address. Asset and amount are encrypted. |
| Rings to wallet | Rings private balance to public balance | Your wallet | Your address, the asset and the amount |
A wallet that has never used Privacy Rings registers a Rings private wallet first: one transaction that publishes the keys others encrypt to.
In the app
Everything is in the Deposit and withdraw panel on Portfolio.
Connect and read your account
Press Connect, choose your wallet, then Sign and read.
Register, if asked
If the panel shows "This wallet has no Rings private wallet yet", press Register a Rings private wallet and approve the transaction.
Choose the asset and the direction
Pick the asset, then one of Wallet to Rings, Rings to Mesa, Mesa to Rings or Rings to wallet. The field shows how much is available on the side you are moving from.
Enter the amount and confirm
Press Review, check the amount and the destination, and press the confirm button: Deposit, Deposit into Mesa, Withdraw or Withdraw to wallet. The panel shows the action being signed, proved and relayed, and then placed.
The Balances table has a column for each place an asset can be: In Mesa, free, In orders and batches, Rings balance and Wallet. A move shows up there when its transaction lands. Press Read again to refresh.
From code
import { openMesaScript } from '@mesa/sdk/node'
const mesa = await openMesaScript({ apiUrl: 'https://api.mesa.markets', keyFile: './wallet.json' })
const account = mesa.mesa
const config = await account.client.config()
const usdc = config.assets.find((a) => a.symbol === 'USDC')!
const amount = 500_000_000n // 500 USDC
if (mesa.snapshot().status === 'not-registered') {
await account.run({ kind: 'register' }, console.log)
}
// in
await account.run({ kind: 'rings_deposit', mint: usdc.mint, amount }, console.log)
await mesa.deposit({ mint: usdc.mint, amount })
// out
await mesa.withdraw({ mint: usdc.mint, amount })
await account.run({ kind: 'rings_withdraw', mint: usdc.mint, amount }, console.log)
mesa.destroy()deposit and withdraw are methods of the handle. Registration and the two moves between the public and the Rings balance go through run. The handle must be opened with a wallet keypair, since three of the four steps are signed by the wallet.
What can stop a move
| You see | Cause | Do |
|---|---|---|
| "More than is available." | The amount exceeds the balance on the sending side | Enter less, or move funds one step closer first |
Insufficient Mesa balance for <mint> | A withdrawal larger than the free Mesa balance | Funds locked in orders and batches return when their batch settles |
Connect a wallet first. | A wallet-signed step on a handle opened from a master secret | Open the handle with the wallet's keypair |
ProtocolPaused | The protocol is paused | Deposits resume when it is unpaused. Withdrawals run while paused. |
TRANSACTION_EXPIRED | The wallet approval took longer than the transaction's lifetime | Start the step again |
Balance notes
A Mesa balance is made of notes, and an action spends one note of the asset. If your balance of an asset is spread over several notes and an action needs more than the largest holds, the SDK merges notes first, with the consolidate action, and then proceeds. The app does the same, since it runs on the SDK.