Skip to main content
This page is under construction. A full API reference documenting all functions, parameters, and return types will be added here.

hre.cofhe

The plugin extends the Hardhat Runtime Environment with a cofhe namespace.

Client creation

MethodDescription
hre.cofhe.createClientWithBatteries(signer?)Creates a fully configured CofheClient with a self-permit. Uses the first signer if none provided.
hre.cofhe.createConfig(options)Wraps createCofheConfig with Hardhat defaults (environment: 'hardhat', encryptDelay: 0).
hre.cofhe.createClient(config)Creates a CofheClient from a config object.
hre.cofhe.connectWithHardhatSigner(client, signer)Connects a client using a HardhatEthersSigner.
hre.cofhe.hardhatSignerAdapter(signer)Returns { publicClient, walletClient } from a Hardhat signer.

hre.cofhe.mocks

MethodDescription
hre.cofhe.mocks.deployMocks()Programmatically deploy mock contracts.
hre.cofhe.mocks.getPlaintext(ctHash)Returns the plaintext bigint for a ciphertext hash.
hre.cofhe.mocks.expectPlaintext(ctHash, expected)Chai assertion shorthand for getPlaintext.
hre.cofhe.mocks.getMockTaskManager()Returns the MockTaskManager contract instance.
hre.cofhe.mocks.getMockACL()Returns the MockACL contract instance.
hre.cofhe.mocks.getMockThresholdNetwork()Returns the MockThresholdNetwork contract instance.
hre.cofhe.mocks.getMockZkVerifier()Returns the MockZkVerifier contract instance.
hre.cofhe.mocks.getTestBed()Returns the TestBed contract instance.
hre.cofhe.mocks.withLogs(name, fn)Wraps a function with labeled FHE operation logging.
hre.cofhe.mocks.enableLogs(label?)Enables FHE operation logging.
hre.cofhe.mocks.disableLogs()Disables FHE operation logging.

Hardhat config

hardhat.config.ts
import '@cofhe/hardhat-plugin';

export default {
  solidity: '0.8.28',
  cofhe: {
    logMocks: true,    // Log FHE operations (default: true)
    gasWarning: true,  // Warn on high mock gas usage (default: true)
  },
};

Hardhat tasks

TaskDescription
task:cofhe-mocks:deployDeploy mock contracts. Options: --deployTestBed, --silent.
task:cofhe-mocks:setlogopsToggle FHE operation logging. Options: --enable.

Pre-configured networks

NetworkURLChain ID
localcofhehttp://127.0.0.1:42069
eth-sepoliaEthereum Sepolia public RPC11155111
arb-sepoliaArbitrum Sepolia public RPC421614