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
- In Terminal, locate the settled fill in the recent fills table and click Copy TVK.
- Programmatically, read
submission.tvkdirectly from the response ofexecuteSwap,fillHiddenOrder,requestAndAcceptRfq, orPOST /v1/transactions/submit. - You can also list past fills for your wallet via
mera.getFills({ wallet, ringId }). The API returnstvkonly when no wallet filter is restricted or when the requestedwalletmatches the fill'stakerormaker.
Verifying a TVK in /receipts
- Open Receipts (no wallet connection is required).
- Paste the
mera_tvk_v1_...string into the verifier input (or load a sample localnet TVK to inspect the format). - Press Verify Receipt.
- Inspect the decrypted receipt card:
- Cryptographic verification badge (
verified: true) confirming the recomputed SHA-256 settlement commitment hash matches the key'scommitmentHash. - On-chain match badge (
onchainMatched: true) confirming theRfqSettlementRecordPDA exists on Solana and is owned bymera_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, andfeeRecipient), 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:
- Strip the
mera_tvk_v1_prefix, base64-decode the remainder, and parse the UTF-8 JSON object (v === 1). - Compute
SHA-256("mera:settlement:v1:" || settlementId || ":" || ringId || ":" || pairId || ":" || inputAmount || ":" || outputAmount || ":" || feeAmount)and confirm the hex digest equalscommitmentHash. - Derive the
RingConfigPDA (["ring", SHA-256(ringId)]) andRfqSettlementRecordPDA (["settlement", ring_pubkey, SHA-256(settlementId)]) undermera_core(3w9NcCZK118PzMLmfbS5si5Q5hpA3DMEuYyfVo5fkE1B). - Fetch the
RfqSettlementRecordaccount directly from any Solana RPC node and confirmrecord.commitment_hash == commitmentHash,record.nullifier_hash == nullifierHash,record.tvk_hint == commitmentHash[0..16],record.fee_paid == BigInt(feeAmount), andrecord.settled_slot == BigInt(slot).
Failure cases
INVALID_TVK(400, malformed): Missingmera_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, orfeeAmount) were modified after settlement.