fhevm-testing
Testing FHE Contracts with Hardhat
Use this skill when setting up a test suite for FHEVM contracts, deciding between mocked and real protocol testing, or diagnosing why tests pass locally but fail on testnet. The encryption layer introduces bugs that only surface under specific runtime conditions.
When To Use
- Setting up a Hardhat test suite for an FHEVM contract
- Choosing between mocked mode and real protocol testing
- Debugging a test that passes locally but fails on testnet
- Writing tests for ACL flows, encrypted inputs, or decryption paths
Core Mental Model
The Hardhat plugin gives you two local mock modes plus one real-encryption mode:
- Hardhat in-memory network: mock encryption, fast, ephemeral
- Hardhat node /
localhost: mock encryption, persistent, useful for local app integration
More from z-korp/fhevm-cookbook
fhevm-router
Routes Zama FHEVM tasks to the right official docs path and next step
11fhevm-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.
11fhevm-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.
11oz-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.
11fhevm-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.
11fhevm-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.
11