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/Protocol & Reference
7 min read

On-Chain Program Reference

Complete mera_core Anchor program reference covering program ID, accounts, PDA seeds, all 11 instructions, and all 8 emit_cpi! events.

mera_core is Mera's Solana Anchor program. It manages protocol configuration, Custom Rings, shielded SPL and Token-2022 vaults, UTXO commitment notes, nullifiers, private escrow limit orders, atomic settlements, and CPI events.

Program identifiers and constants

ConstantValue
Program namemera_core
Program ID3w9NcCZK118PzMLmfbS5si5Q5hpA3DMEuYyfVo5fkE1B
MAX_FEE_BPS500 (5.00% maximum protocol fee)
MAX_RING_NAME48 bytes (valid length 2..=48)
Anchor event transport#[event_cpi] / emit_cpi! (inner instruction tag e445a52e51cb9a1d, signer PDA ["__event_authority"])

Accounts and PDA seeds

All account sizes below exclude the 8-byte Anchor discriminator (space = 8 + SPACE).

ProtocolConfig

PDA seeds: ["protocol"] (SPACE = 84 bytes, total 92 bytes).

FieldTypeDescription
adminPubkeyAuthority allowed to call update_protocol_fee
fee_recipientPubkeyWallet whose ATA receives fee_paid on every settlement
fee_bpsu16Execution fee in basis points (<= 500)
pausedboolHalts ring creation, deposits, order placement, and settlements when true
total_ringsu64Count of initialized RingConfig accounts
total_settlementsu64Count of cleared settlements across all Rings
bumpu8Canonical PDA bump

RingConfig

PDA seeds: ["ring", ring_id_hash] where ring_id_hash = SHA-256(ring_id) (SPACE = 193 bytes, total 201 bytes).

FieldTypeDescription
ring_id_hash[u8; 32]32-byte hash of the Ring identifier
nameStringRing display name (2..=48 bytes)
authorityPubkeyWallet allowed to manage RingMember accounts
auditor_pubkeyPubkeyDesignated auditor public key (Pubkey::default() if none)
modeu80 = Confidential, 1 = Anonymous
allowlist_enabledboolWhether allowlist enforcement is active
frozenboolBlocks deposits, withdrawals, orders, and settlements when true
is_defaultboolMarks the permissionless Default Ring
commitment_root[u8; 32]Rolling SHA-256 accumulator of all commitments created in the Ring
commitment_countu64Total commitments appended to commitment_root
settlement_countu64Total settlements cleared in the Ring
bumpu8Canonical PDA bump

RingMember

PDA seeds: ["ring_member", ring_config, member_wallet] (SPACE = 67 bytes, total 75 bytes).

FieldTypeDescription
ringPubkeyParent RingConfig PDA
memberPubkeyMember wallet public key
allowedboolWhether the wallet is allowlisted in the Ring
frozenboolWhether the wallet is frozen in the Ring
bumpu8Canonical PDA bump

ShieldedVault

PDA seeds: ["vault", ring_config, mint] (SPACE = 121 bytes, total 129 bytes). Owns the associated token account vault_token_account for (shielded_vault, mint).

FieldTypeDescription
ringPubkeyParent RingConfig PDA
mintPubkeySPL or Token-2022 mint
token_accountPubkeyVault ATA owned by this PDA
total_shieldedu64Total shielded token base units held in the vault
total_locked_escrowu64Portion of shielded units currently locked in open PrivateEscrowOrder accounts
total_fees_collectedu64Cumulative protocol fees transferred out to fee_recipient
bumpu8Canonical PDA bump

CommitmentNote

PDA seeds: ["note", ring_config, commitment] (SPACE = 146 bytes, total 154 bytes).

FieldTypeDescription
ringPubkeyParent RingConfig PDA
mintPubkeyToken mint
ownerPubkeyOwner wallet
commitment[u8; 32]32-byte note commitment
amountu64Shielded token base units
spentboolSet to true when consumed by withdrawal, escrow placement, or settlement
created_slotu64Solana slot when created
bumpu8Canonical PDA bump

NullifierRecord

PDA seeds: ["nullifier", ring_config, nullifier] (SPACE = 73 bytes, total 81 bytes).

FieldTypeDescription
ringPubkeyParent RingConfig PDA
nullifier[u8; 32]Unique 32-byte nullifier
spent_slotu64Solana slot when spent
bumpu8Canonical PDA bump

PrivateEscrowOrder

PDA seeds: ["escrow", ring_config, maker, order_id_hash] (SPACE = 250 bytes, total 258 bytes).

FieldTypeDescription
ringPubkeyParent RingConfig PDA
makerPubkeyOrder maker wallet
base_mintPubkeyPair base mint
quote_mintPubkeyPair quote mint
escrow_mintPubkeyMint locked in escrow (base_mint for sell, quote_mint for buy)
sideu80 = buy, 1 = sell
limit_price_e6u64Limit price scaled by 1_000_000
size_commitment[u8; 32]32-byte encrypted size commitment
locked_amountu64Escrowed token base units
expiry_slotu64Slot after which anyone can expire and refund the order
statusu80 = open, 1 = filled, 2 = cancelled by maker, 3 = expired
input_notePubkeySpent CommitmentNote PDA that funded the escrow
bumpu8Canonical PDA bump

RfqSettlementRecord

PDA seeds: ["settlement", ring_config, settlement_id_hash] (SPACE = 226 bytes, total 234 bytes).

FieldTypeDescription
ringPubkeyParent RingConfig PDA
settlement_id_hash[u8; 32]32-byte hash of the settlement ID
modeu80 = swap, 1 = hidden-order fill, 2 = sealed-rfq
base_mintPubkeyBase or input mint
quote_mintPubkeyQuote or output mint
commitment_hash[u8; 32]SHA-256 settlement commitment hash checked by TVK verification
nullifier_hash[u8; 32]Taker input nullifier hash
tvk_hint[u8; 16]First 16 bytes of commitment_hash
fee_paidu64Protocol fee paid in settlement mint base units
settled_slotu64Solana slot when settled
bumpu8Canonical PDA bump

Instructions

InstructionSignersArgumentsState transitions & events
init_protocoladminfee_bps: u16Initializes ProtocolConfig with fee_recipient and fee_bps <= 500. Emits ProtocolInitialized.
update_protocol_feeadminfee_bps: u16, fee_recipient: Pubkey, paused: boolUpdates global fee rate (<= 500), fee recipient, and pause flag.
create_ringauthorityring_id_hash: [u8; 32], name: String, mode: u8, allowlist_enabled: bool, is_default: bool, auditor_pubkey: PubkeyInitializes RingConfig, increments ProtocolConfig.total_rings. Emits RingCreated.
set_ring_memberauthorityallowed: bool, frozen: boolCreates or updates RingMember for member_wallet (enforces ring_config.authority == authority). Emits RingMemberUpdated.
deposit_shieldeduseramount: u64, commitment: [u8; 32]Transfers amount from user_token_account to vault_token_account, initializes ShieldedVault if needed, initializes CommitmentNote, updates commitment_root. Emits ShieldedDeposited.
withdraw_shieldeduseramount: u64, nullifier: [u8; 32]Marks commitment_note.spent = true, initializes NullifierRecord, transfers amount from vault_token_account to recipient_token_account, decrements total_shielded. Emits ShieldedWithdrawn.
place_hidden_ordermakerorder_id_hash: [u8; 32], side: u8, limit_price_e6: u64, size_commitment: [u8; 32], amount: u64, nullifier: [u8; 32], expiry_slot: u64Spends input_note, creates NullifierRecord, increments escrow_vault.total_locked_escrow, initializes PrivateEscrowOrder. Emits HiddenOrderPlaced.
cancel_hidden_ordercallerrefund_commitment: [u8; 32]Allowed if caller == escrow.maker (status = 2) or clock.slot >= escrow.expiry_slot (status = 3). Decrements total_locked_escrow, creates refund_note for escrow.maker, updates commitment_root. Emits HiddenOrderCancelled.
fill_hidden_ordertakersettlement_id_hash: [u8; 32], taker_nullifier: [u8; 32], maker_out_commitment: [u8; 32], taker_out_commitment: [u8; 32], taker_amount: u64, commitment_hash: [u8; 32], tvk_hint: [u8; 16]Spends taker_input_note, creates taker_nullifier_record, transfers fee_paid from taker_vault to fee_recipient_token_account, marks escrow.status = 1, creates maker_output_note and taker_output_note, initializes RfqSettlementRecord (mode = 1). Emits SettlementCleared.
settle_confidential_swaptaker, makersettlement_id_hash: [u8; 32], taker_nullifier: [u8; 32], maker_nullifier: [u8; 32], taker_out_commitment: [u8; 32], maker_out_commitment: [u8; 32], input_amount: u64, output_amount: u64, commitment_hash: [u8; 32], tvk_hint: [u8; 16]Spends both input notes, creates both nullifiers, transfers fee_paid from output_vault to fee_recipient_token_account, creates output notes for taker (output_amount - fee_paid) and maker (input_amount), initializes RfqSettlementRecord (mode = 0). Emits SettlementCleared.
settle_sealed_rfqtaker, makerSame arguments as settle_confidential_swapSame atomic two-sided settlement with RfqSettlementRecord.mode = 2. Emits SettlementCleared.

CPI events

All 8 events are emitted via emit_cpi! so they survive Solana's 10,000-byte transaction log limit:

EventFields
ProtocolInitializedadmin, fee_recipient, fee_bps
RingCreatedring, ring_id_hash, authority, mode, allowlist_enabled, auditor_pubkey
RingMemberUpdatedring, member, allowed, frozen
ShieldedDepositedring, mint, owner, commitment, slot
ShieldedWithdrawnring, mint, owner, nullifier, slot
HiddenOrderPlacedring, order, order_id_hash, side, limit_price_e6, size_commitment, expiry_slot, slot
HiddenOrderCancelledring, order, status, refund_commitment, slot
SettlementClearedring, settlement, settlement_id_hash, mode, commitment_hash, tvk_hint, fee_paid, slot

For every MeraError code (6000 through 6014), see Error Codes.