Mera
ExecutionInstant confidential swapsClear from encrypted balances in one 150ms slot.Hidden-size limit ordersLock encrypted size in a private escrow PDA.Sealed RFQ block tradesRequest signed quotes without leaking size.
Vault & AuditShielded vault & keysDeposit SOL, SPL, or Token-2022 into a Ring.Viewing key verifierDecrypt and prove a single settled fill.
Docs/Getting Started
3 min read

Shielding Assets

Deposit SOL, SPL, and Token-2022 assets into a Ring ShieldedVault PDA, manage commitment notes, and withdraw back to a public wallet.

Every trade on Mera settles from a shielded balance inside a Ring. Shielding transfers public tokens into the Ring's ShieldedVault PDA and mints an encrypted CommitmentNote PDA owned by your wallet. Unshielding spends a note with a one-time nullifier and transfers public tokens back to any recipient address.

Both deposits and withdrawals carry a 0 bps protocol fee. You pay only the standard Solana transaction fee and account rent for newly created note or nullifier PDAs.

Supported assets

SymbolNameDecimalsStandard
SOLSolana9Native / Wrapped (So11111111111111111111111111111111111111112)
USDCUSD Coin6SPL
wBTCWrapped Bitcoin8SPL
wETHWrapped Ether8SPL
JitoSOLJito Staked SOL9SPL

For native SOL, the deposit builder prepends idempotent wrapped-SOL ATA creation, a SystemProgram.transfer for the deposit amount, and SyncNative before invoking deposit_shielded. You do not need to wrap SOL manually.

Shielding assets (deposit)

In the web terminal

  1. Open Vault and select the target Ring (ring-default or a Custom Ring where your wallet is allowlisted).
  2. Choose an asset from the supported list and enter the deposit amount.
  3. Press Shield Assets and sign the transaction in your wallet.
  4. Once confirmed, your shielded balance and encrypted note count update immediately.

With the TypeScript SDK

ts
import { createMeraClient, keypairSigner } from '@mera/sdk'

const mera = createMeraClient({
  apiUrl: 'http://127.0.0.1:36102',
  signer: keypairSigner(myKeypair),
})

const { items: mints } = await mera.getMints()
const usdc = mints.find((m) => m.symbol === 'USDC')!

const res = await mera.shieldDeposit({
  ringId: 'ring-default',
  mint: usdc.mint,
  amount: '250000000', // 250 USDC (6 decimals)
})

console.log(res.status, res.signature, res.slot)

What happens on chain

deposit_shielded verifies the protocol is not paused and the Ring is not frozen, runs token_interface::transfer_checked from the user's ATA into the Ring's vault_token_account, increments ShieldedVault.total_shielded, initializes a CommitmentNote PDA at seeds ["note", ring, commitment], updates RingConfig.commitment_root to SHA-256(old_root || commitment), and emits a ShieldedDeposited event via emit_cpi!.

Inspecting shielded balances and notes

Call GET /v1/balances/:wallet?ringId=ring-default (or mera.getBalances(wallet, ringId)) to inspect public balances, shielded balances, locked escrow balances, and individual unspent CommitmentNote entries.

ts
const snapshot = await mera.getBalances(myKeypair.publicKey.toBase58(), 'ring-default')

console.log('Viewing key fingerprint:', snapshot.viewingKeyFingerprint)
for (const entry of snapshot.balances) {
  console.log(
    entry.symbol,
    'public:', entry.publicBalance,
    'shielded:', entry.shieldedBalance,
    'locked:', entry.lockedEscrowBalance,
    'notes:', entry.noteCount,
  )
}

Unshielding assets (withdraw)

Withdrawals spend one unspent CommitmentNote whose balance is greater than or equal to the requested amount, create a NullifierRecord PDA at seeds ["nullifier", ring, nullifier] to prevent double-spends, decrement ShieldedVault.total_shielded, and transfer tokens from vault_token_account to the recipient's ATA.

In the web terminal

  1. Open Vault and switch to the Unshield action.
  2. Select the asset, enter the withdrawal amount, and optionally specify a different recipient Solana address.
  3. Press Unshield and sign the transaction.

With the TypeScript SDK

ts
const withdraw = await mera.shieldWithdraw({
  ringId: 'ring-default',
  mint: usdc.mint,
  amount: '100000000', // 100 USDC
  recipient: 'RecipientPublicKeyBase58...', // optional; defaults to signer wallet
})

console.log('Unshielded:', withdraw.signature)
NOTE
If you hold multiple small notes and none individually covers the requested withdrawal amount, specify noteId to withdraw a single note at a time. The API returns INSUFFICIENT_SHIELDED_BALANCE (400) when no unspent note covers the requested amount.

Failure cases

  • RING_ACCESS_DENIED (403): The target Custom Ring has an allowlist enabled and your wallet is not allowlisted.
  • RING_FROZEN (403): Either the Ring itself or your wallet's RingMember record is frozen.
  • INSUFFICIENT_SHIELDED_BALANCE (400): No unspent CommitmentNote in the Ring covers the requested withdrawal amount.
  • NoteAlreadySpent (6006): The referenced CommitmentNote has already been nullified on chain.