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.

StepMovesSigned byThe chain shows
Wallet to RingsPublic balance to Rings private balanceYour walletYour address, the asset and the amount
Rings to MesaRings private balance to a Mesa balance noteYour walletYour address. Asset and amount are encrypted.
Mesa to RingsMesa balance to Rings private balanceNobody. It is proved and relayed.The receiving address. Asset and amount are encrypted.
Rings to walletRings private balance to public balanceYour walletYour 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.

  1. Connect and read your account

    Press Connect, choose your wallet, then Sign and read.

  2. 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.

  3. 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.

  4. 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

move.ts
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 seeCauseDo
"More than is available."The amount exceeds the balance on the sending sideEnter less, or move funds one step closer first
Insufficient Mesa balance for <mint>A withdrawal larger than the free Mesa balanceFunds 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 secretOpen the handle with the wallet's keypair
ProtocolPausedThe protocol is pausedDeposits resume when it is unpaused. Withdrawals run while paused.
TRANSACTION_EXPIREDThe wallet approval took longer than the transaction's lifetimeStart 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.