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/Guides
2 min read

Auditing with Viewing Keys

Export a Transaction Viewing Key from a settled fill and verify it in /receipts or programmatically via @mera/sdk.

Every settled swap, hidden-size limit order fill, and sealed RFQ block trade emits a single-transaction Transaction Viewing Key (TVK). Either counterparty can hand that key to an auditor, accountant, or counterparty to verify exact trade terms without revealing any other balance or transaction in the wallet.

Exporting a TVK after a trade

  1. In Terminal, locate the settled fill in the recent fills table and click Copy TVK.
  2. Programmatically, read submission.tvk directly from the response of executeSwap, fillHiddenOrder, requestAndAcceptRfq, or POST /v1/transactions/submit.
  3. You can also list past fills for your wallet via mera.getFills({ wallet, ringId }). The API returns tvk only when no wallet filter is restricted or when the requested wallet matches the fill's taker or maker.

Verifying a TVK in /receipts

  1. Open Receipts (no wallet connection is required).
  2. Paste the mera_tvk_v1_... string into the verifier input (or load a sample localnet TVK to inspect the format).
  3. Press Verify Receipt.
  4. Inspect the decrypted receipt card:
  • Cryptographic verification badge (verified: true) confirming the recomputed SHA-256 settlement commitment hash matches the key's commitmentHash.
  • On-chain match badge (onchainMatched: true) confirming the RfqSettlementRecord PDA exists on Solana and is owned by mera_core.
  • Trade breakdown: Ring name and ID, pair, execution mode (swap, hidden-order, sealed-rfq), side, exact input amount, exact net output amount, execution price, exact protocol fee (feeAmount, feeBps, and feeRecipient), slot, finality ms, and Solana transaction signature.

Verifying a TVK with @mera/sdk

Auditors and back-office systems can verify TVKs without a wallet or signer:

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

const auditorClient = createMeraClient({
  apiUrl: 'http://127.0.0.1:36102',
})

const receipt = await auditorClient.verifyTvk(tvkString)

console.log({
  verified: receipt.verified,
  onchainMatched: receipt.onchainMatched,
  ring: `${receipt.ringName} (${receipt.ringId})`,
  pair: receipt.pairId,
  mode: receipt.mode,
  side: receipt.side,
  inputAmount: receipt.inputAmount,
  outputAmount: receipt.outputAmount,
  executionPrice: receipt.executionPrice,
  feeAmount: receipt.feeAmount,
  feeBps: receipt.feeBps,
  feeRecipient: receipt.feeRecipient,
  slot: receipt.slot,
  finalityMs: receipt.finalityMs,
  signature: receipt.signature,
})

You can also verify via HTTP GET /v1/receipts/:tvk (URL-encoded) or POST /v1/receipts/verify with JSON body { "tvk": "mera_tvk_v1_..." }.

Independent offline verification

Any compliance tool can verify a TVK's integrity independently of Mera's API:

  1. Strip the mera_tvk_v1_ prefix, base64-decode the remainder, and parse the UTF-8 JSON object (v === 1).
  2. Compute SHA-256("mera:settlement:v1:" || settlementId || ":" || ringId || ":" || pairId || ":" || inputAmount || ":" || outputAmount || ":" || feeAmount) and confirm the hex digest equals commitmentHash.
  3. Derive the RingConfig PDA (["ring", SHA-256(ringId)]) and RfqSettlementRecord PDA (["settlement", ring_pubkey, SHA-256(settlementId)]) under mera_core (3w9NcCZK118PzMLmfbS5si5Q5hpA3DMEuYyfVo5fkE1B).
  4. Fetch the RfqSettlementRecord account directly from any Solana RPC node and confirm record.commitment_hash == commitmentHash, record.nullifier_hash == nullifierHash, record.tvk_hint == commitmentHash[0..16], record.fee_paid == BigInt(feeAmount), and record.settled_slot == BigInt(slot).

Failure cases

  • INVALID_TVK (400, malformed): Missing mera_tvk_v1_ prefix, invalid base64, invalid JSON, or missing required fields.
  • INVALID_TVK (400, commitment mismatch): One or more trade fields (settlementId, ringId, pairId, inputAmount, outputAmount, or feeAmount) were modified after settlement.