System diagram
Layer 1: frontend
The frontend is a Next.js 16 application using React 19 with server components, API routes, and Turbopack for fast local development.Pages
| Route | Purpose |
|---|---|
/ | Token registry — browse all confidential tokens created through the factory |
/create | Multi-step token creation wizard |
/token/[address] | Token detail page with encrypted transfer, mint, burn, and observer controls |
/portfolio | Private portfolio — wrap/unwrap ERC-20s, decrypt all balances in one signature |
/payments | Send any ERC-20 confidentially; batch payment support |
/pay/[txHash] | Payer UI for fulfilling a payment link — resolves linkId from the creation transaction hash |
Wallet and contract interaction
Wagmi 2 manages all contract reads and writes. RainbowKit 2 handles wallet connection UI. Contract ABIs are stored as JSON files underfrontend/src/lib/abi/.
TFHE WASM (client-side encryption)
The Zama Relayer SDK ships two WASM bundles served as static assets:public/sdk/tfhe_bg.wasm— TFHE cryptographic operationspublic/sdk/kms_lib_bg.wasm— KMS client library
encryptAmount() encrypts a uint64 value client-side and returns an externalEuint64 handle and an inputProof that the contract verifies via FHE.fromExternal():
API routes
The Next.js app exposes three internal API routes used for KMS-related operations:| Route | Purpose |
|---|---|
/api/decrypt/user-decrypt | Mini-relayer for user balance decryption. Proxies EIP-712 signed requests to the Zama KMS gateway. The decrypted value is returned encrypted under your ephemeral public key — the server never sees plaintext. |
/api/decrypt/public-decrypt | Handles public decryption requests (used for unwrap/payment flows). |
/api/decrypt/input-proof | Proxies input-proof verification requests from the TFHE SDK. |
/api/decrypt/keyurl | Returns the Zama KMS key URL for the SDK initialization. |
/api/relayer/request-decrypt | Submits a public decryption request to the Gateway Chain for unwrap/payment finalization. |
/api/relayer/poll-decrypt | Polls the Gateway Chain for a completed decryption response. |
/api/relayer/submit-finalize | Submits the finalization transaction (finalizeUnwrap or finalize) once the KMS proof is ready. |
Layer 2: Ethereum mainnet
Six immutable contracts deployed on Ethereum mainnet store and process encrypted state.Contract interaction graph
Contract responsibilities
HideMeFactory
The factory deploys
HideMeToken instances and stores on-chain metadata (name, symbol, supply, description, logo URI, website). It provides paginated querying so the frontend registry can enumerate all tokens.HideMeToken
The core confidential ERC-20. Balances are
euint64 ciphertexts. All arithmetic — add, subtract, compare — executes on encrypted data. Three transfer modes are supported: client-side encrypted input (transfer with externalEuint64), existing ciphertext (transfer with euint64), and on-chain encryption (transferPlaintext).WrapperFactory
Deploys one
ConfidentialWrapper per ERC-20 address, enforcing uniqueness. Provides lookup so the payment router can resolve a token address to its wrapper.ConfidentialWrapper
Converts any standard ERC-20 into a confidential cToken. Wrapping transfers the ERC-20 into the contract and mints an encrypted balance. Unwrapping is a 2-step async operation: the contract marks a boolean ciphertext for public decryption, the KMS provides threshold signatures, and
finalizeUnwrap() verifies the proof before releasing funds.ConfidentialPaymentRouterV2
Orchestrates one-click confidential payments. The sender’s amount is encrypted on-chain during wrapping; the receiver gets plain ERC-20 without ever interacting with FHE. Requires a minimum 0.00005 ETH relayer fee to cover finalization gas.
Layer 3: Zama infrastructure
KMS network
The Zama KMS is a threshold key management network. It holds the FHE master key, distributed across independent nodes. Decryption of any ciphertext requires a quorum of nodes to independently sign the decryption result — no single node can act alone. The KMS handles two decryption paths:- User decrypt — initiated by your wallet’s EIP-712 signature. Used when you read your own balance. The result is returned encrypted under your temporary public key.
- Public decrypt — initiated on-chain when a contract calls
FHE.makePubliclyDecryptable(). Used for unwrap and payment finalization. The KMS returns threshold signatures that are verified byFHE.checkSignatures()before any funds move.
Gateway Chain
The Gateway Chain acts as a coordination layer between Ethereum mainnet and the KMS. WhenFHE.makePubliclyDecryptable(handle) is called on mainnet, the Gateway Chain picks up the event, requests decryption from the KMS nodes, collects their threshold signatures, and relays the signed proof back to mainnet for on-chain verification.
Contract reference
Deployed addresses, ABI details, and per-contract function reference.
Privacy model
How FHE ciphertexts, silent failures, and the observer model protect your balances.
Trust assumptions
What you trust when using HideMe, and the design decisions that bound that trust.