fhevm-router
fhevm-router
Use this router when you are working on Zama FHEVM and need the smallest correct next step.
Use this router when the task has not yet been narrowed to a more specific local skill. Only rely
on specialist cookbook modules that are actually present in this repo's skills/ directory —
do not route to a module that has not been installed.
Specialist modules in this cookbook:
oz-erc7984-confidential-tokensfhevm-privacy-constraintsfhevm-acl-lifecyclefhevm-control-flowfhevm-encrypted-inputsfhevm-user-decryptionfhevm-public-decryptionfhevm-frontend-integrationfhevm-arithmetic-opsfhevm-security-auditoz-erc7984-compliance-patternsfhevm-testingfhevm-cross-contractoz-erc7984-confidential-governanceoz-erc7984-custodian-omnibusfhevm-token-registryoz-utils-safemath
What this skill does
- identifies whether the task is contract-side, frontend-side, wallet-side, or review-oriented
- points to the narrowest official Zama docs page or pages that match the task
- points back to the official Zama docs that should remain the source of truth
- keeps the installed skill set explicit instead of routing to modules that aren't available
Decision tree: pick the right specialist skill
Work top-down. Start with the first matching row, then add any other relevant skills. If nothing matches, fall back to the Zama docs below.
- Auditing or reviewing contract code for correctness?
→
fhevm-security-audit(then pull in any domain-specific skill below) - Product design: can this feature even exist given what FHE hides?
→
fhevm-privacy-constraintsbefore anything else - Contract authoring — choose by what the code is doing:
- granting
FHE.allow/allowThis/allowTransient, debugging inaccessible handles →fhevm-acl-lifecycle - accepting
externalEuint64+inputProoffrom a user →fhevm-encrypted-inputs FHE.add/sub/mul/div, comparisons, overflow, type casts →fhevm-arithmetic-ops- overflow-safe balance updates on encrypted
euint64(tryIncrease/tryDecrease/tryAdd/trySub) →oz-utils-safemath - replacing
if/requirewithFHE.select, handling silent fallbacks →fhevm-control-flow - passing handles across contracts, multi-contract ACL flows →
fhevm-cross-contract
- granting
- Decryption — which side needs the plaintext?
- user's browser reading their own state (read-only, no gas) →
fhevm-user-decryption - contract must act on plaintext (unwrap, settlement, two-step + proof) →
fhevm-public-decryption
- user's browser reading their own state (read-only, no gas) →
- Frontend / SDK integration (WASM, SSR, wallet, encryption hooks) →
fhevm-frontend-integration - Known token deployment lookup (address, underlying ERC20, decimals, start block, wrappers registry)
→
fhevm-token-registry - Tests pass locally but fail on testnet; deciding mocked vs real protocol →
fhevm-testing - Regulatory / compliance controls (observers, freezing, blocklists, RWA) →
oz-erc7984-compliance-patterns - Building a specific application:
- confidential fungible token (ERC7984, wrappers, operators, unwrap) →
oz-erc7984-confidential-tokens - governance with encrypted voting power (ERC7984Votes) →
oz-erc7984-confidential-governance - exchange custody, omnibus accounts, sub-account ledgers →
oz-erc7984-custodian-omnibus
- confidential fungible token (ERC7984, wrappers, operators, unwrap) →
If the task spans multiple rows (common), start with the first applicable row above, then add any other relevant skills in that same order: audit first, then product framing, then mechanics, then application.
Route by task
- Contract authoring with encrypted types, ACL, and inputs
- Frontend or app-side user decryption
- Public decryption plus onchain verification and state finalization
- Relayer SDK setup inside React or Next.js
- Wallet or exchange support for ERC7984 flows
- Known confidential token deployment or wrappers registry lookup
- Use
fhevm-token-registryas the source of truth for deployment addresses, decimals, and start blocks - Keep open: https://docs.zama.org/protocol/protocol-apps/registry-contract
- Use
- Testing or debugging
- Security review
Operating rules
- start with the first matching row, then add any other relevant skills
- cite the exact official Zama docs page for protocol semantics and API details
- keep ACL, trust boundaries, and decryption boundaries explicit
- if the task spans contract and frontend work, split the plan by boundary before writing code
- if a specialized cookbook module is not installed, stay in router mode and work from docs
Local skill handoff
Core FHE Mechanics
- For ACL grants, handle permissions, FHE.allow/allowThis/allowTransient, and debugging inaccessible handles:
use
fhevm-acl-lifecycle - For client-side encryption, FHE.fromExternal, inputProof binding, and external vs onchain handles:
use
fhevm-encrypted-inputs - For FHE arithmetic (add/sub/mul/div), comparisons, bitwise ops, overflow, and type casting:
use
fhevm-arithmetic-ops - For replacing if/else/require with FHE.select, silent-failure semantics, and encrypted branching:
use
fhevm-control-flow
Decryption
- For client-side balance display, useUserDecrypt hook, reencryption protocol, and read-only decryption:
use
fhevm-user-decryption - For two-step public decryption, makePubliclyDecryptable, checkSignatures, and unwrap finalization:
use
fhevm-public-decryption
Tokens & Privacy
- For ERC7984 token design, wrappers, operators, transfer variants, and unwrap correctness:
use
oz-erc7984-confidential-tokens - For rewards, analytics, balance inference limits, ACL-driven product constraints, and privacy tradeoffs:
use
fhevm-privacy-constraints
Security & Compliance
- For auditing FHEVM contracts — ACL completeness, silent fallbacks, handle lifecycle, and security review:
use
fhevm-security-audit - For regulatory compliance — observer access, freezing, blocklists, allowlists, and RWA controls:
use
oz-erc7984-compliance-patterns
Operations
- For testing FHE contracts — Hardhat plugin, mock utils, debug decrypt, and E2E validation:
use
fhevm-testing - For overflow-safe encrypted arithmetic on
euint64with the OZ FHESafeMath library (tryIncrease / tryDecrease / tryAdd / trySub): useoz-utils-safemath
Frontend & Advanced
- For Zama SDK initialization, client-side encryption/decryption, WASM setup, and wallet integration:
use
fhevm-frontend-integration - For passing encrypted handles between contracts, multi-contract ACL flows, and DeFi composability:
use
fhevm-cross-contract - For confidential governance — ERC7984Votes, encrypted voting power, and private ballot casting:
use
oz-erc7984-confidential-governance - For omnibus and custodian patterns — ERC7984Omnibus, sub-accounts, and exchange custody:
use
oz-erc7984-custodian-omnibus - For looking up Zama confidential token addresses, their underlying ERC20, decimals, or deployment start blocks on Sepolia or mainnet:
use
fhevm-token-registry
Fallback overviews
Use these only when no narrower page above clearly fits the task:
- Solidity guides: https://docs.zama.org/protocol/solidity-guides
- Relayer SDK guides: https://docs.zama.org/protocol/relayer-sdk-guides
- Examples: https://docs.zama.org/protocol/examples
More from z-korp/fhevm-cookbook
fhevm-testing
Use when writing, structuring, or debugging tests for FHEVM contracts. Covers mocked mode vs real protocol, Hardhat decrypt helpers, input encryption in tests, and the false-confidence gap between local and testnet behavior.
10fhevm-acl-lifecycle
Use when granting, auditing, or debugging ACL permissions on encrypted handles in FHEVM. Covers FHE.allow, FHE.allowThis, FHE.allowTransient, and the critical rule that new handles do not inherit prior persistent ACL grants.
10fhevm-control-flow
Use when replacing if/else, require, or any conditional logic that depends on encrypted values in FHEVM. Covers FHE.select as the inline branching primitive, fallback semantics on encrypted conditions, and async public decryption when logic must branch back to plaintext state.
10oz-utils-safemath
Use when you need overflow-safe encrypted arithmetic on euint64 values. Covers the OpenZeppelin FHESafeMath library (tryIncrease, tryDecrease, tryAdd, trySub), uninitialized-handle semantics, and when to prefer it over raw FHE.add / FHE.sub.
10fhevm-public-decryption
Use when implementing two-step public decryption for state-changing operations in FHEVM. Covers makePubliclyDecryptable, off-chain proof retrieval, onchain verification with checkSignatures, and the critical single-step unwrap bug.
10fhevm-cross-contract
Use when passing encrypted handles between contracts, designing multi-contract FHE flows, or debugging handle-not-accessible errors at contract boundaries. Covers allowTransient, allow, permission chains, and factory patterns.
10