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
| Symbol | Name | Decimals | Standard |
|---|---|---|---|
SOL | Solana | 9 | Native / Wrapped (So11111111111111111111111111111111111111112) |
USDC | USD Coin | 6 | SPL |
wBTC | Wrapped Bitcoin | 8 | SPL |
wETH | Wrapped Ether | 8 | SPL |
JitoSOL | Jito Staked SOL | 9 | SPL |
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
- Open Vault and select the target Ring (
ring-defaultor a Custom Ring where your wallet is allowlisted). - Choose an asset from the supported list and enter the deposit amount.
- Press Shield Assets and sign the transaction in your wallet.
- Once confirmed, your shielded balance and encrypted note count update immediately.
With the TypeScript SDK
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.
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
- Open Vault and switch to the Unshield action.
- Select the asset, enter the withdrawal amount, and optionally specify a different recipient Solana address.
- Press Unshield and sign the transaction.
With the TypeScript SDK
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)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'sRingMemberrecord is frozen.INSUFFICIENT_SHIELDED_BALANCE(400): No unspentCommitmentNotein the Ring covers the requested withdrawal amount.NoteAlreadySpent(6006): The referencedCommitmentNotehas already been nullified on chain.