@cofhe/hardhat-3-plugin is the Hardhat 3 counterpart to @cofhe/hardhat-plugin. It deploys the CoFHE mock contracts to an in-process Hardhat network on every network.connect() call and exposes a cofhe namespace on the connection object — ready to use immediately, no boilerplate required.
Use this plugin if you’ve adopted the Hardhat 3 plugin/hook model. For Hardhat v2 projects, use
@cofhe/hardhat-plugin instead.What the plugin provides
- Auto-deploys mocks on every
network.connect()—MockTaskManager,MockACL,MockZkVerifier,MockThresholdNetwork, andTestBed. conn.cofhenamespace on the Hardhat 3 connection object (sits alongsideconn.viemfrom@nomicfoundation/hardhat-viem).cofhe.createClientWithBatteries()— one-call SDK client setup with a pre-signed self permit.- Mock helpers — Viem contract descriptors for every mock, plaintext inspection (
getPlaintext/expectPlaintext), and logging control.
Installation
1
Install the package
2
Register the plugin
hardhat.config.ts
Configuration
The plugin adds an optionalcofhe key to your Hardhat 3 config. All values shown below are their defaults:
hardhat.config.ts
How auto-deployment works
Every call tonetwork.connect() automatically:
- Deploys all CoFHE mock contracts to the fresh in-process EVM.
- Attaches a
cofhenamespace to the returned connection object.
network.connect() is awaitable at the top level of an async describe, you can set everything up without lifecycle hooks:
Mock contracts deployed
Fixed-address contracts are deployed via
hardhat_setCode, so they are always at the same address regardless of deployment order. MockACL is deployed as a normal contract (so its EIP-712 domain constructor runs correctly) and its address is registered in MockTaskManager.
Differences from @cofhe/hardhat-plugin
The Solidity surface (mock contracts, plaintext semantics,
FHE.verifyDecryptResult acceptance) is identical between the two plugins; the differences are all in how Hardhat hosts the plugin.
Next steps
- Client —
conn.cofhe.createConfig,createClient,createClientWithBatteries. - Mock Contracts — Viem contract descriptors and plaintext inspection helpers.
- Logging —
enableLogs,disableLogs,withLogs. - Testing — end-to-end test patterns.