Documentation Index
Fetch the complete documentation index at: https://fhenix-docs-task-manager-enabled-flag.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
This page summarizes the public surface of @cofhe/foundry-plugin. For task-oriented walkthroughs, see Getting Started and Testing.
CofheTest
Abstract test base. Inherit it instead of forge-std/Test (it inherits Test for you).
import { CofheTest } from "@cofhe/foundry-plugin/contracts/CofheTest.sol";
Setup
| Function | Description |
|---|
deployMocks() | Deploy MockTaskManager, MockACL, MockZkVerifier, MockZkVerifierSigner, MockThresholdNetwork, MockThresholdNetworkSigner. Wires them via setACLContract / setVerifierSigner / setDecryptResultSigner. Funds the ZK signer with 10 ether. Call once in setUp(). |
createCofheClient() | Returns a fresh CofheClient. Follow with client.connect(pkey). |
Plaintext reads
| Function | Description |
|---|
getPlaintext(bytes32 handle) | Returns the raw bytes32 plaintext from MockTaskManager.mockStorage. |
getPlaintext(ebool) / (euint8) / (euint16) / (euint32) / (euint64) / (euint128) / (eaddress) | Typed overloads returning bool / uint8–uint128 / address. |
expectPlaintext(handle, value) | Assertion variant — typed overloads for the same set. |
expectPlaintext(handle, value, "msg") | With assertion message. |
Reverts if the handle isn’t in mock storage.
Logging
| Function | Description |
|---|
enableLogs() | Calls mockTaskManager.setLogOps(true). |
disableLogs() | Calls mockTaskManager.setLogOps(false). |
Public state
| Field | Type |
|---|
mockTaskManager | MockTaskManager |
mockAcl | MockACL |
mockZkVerifier | MockZkVerifier |
mockZkVerifierSigner | MockZkVerifierSigner |
mockThresholdNetwork | MockThresholdNetwork |
mockThresholdNetworkSigner | MockThresholdNetworkSigner |
CofheClient
Per-user shim. One client per scenario address.
import { CofheClient } from "@cofhe/foundry-plugin/contracts/CofheClient.sol";
Connection
| Function | Description |
|---|
connect(uint256 pkey) | Set the connected account to vm.addr(pkey). Required before any createIn* or permit_* call. |
account() | Returns the connected address. |
| Function | Returns |
|---|
createInEbool(bool) | InEbool |
createInEuint8(uint8) | InEuint8 |
createInEuint16(uint16) | InEuint16 |
createInEuint32(uint32) | InEuint32 |
createInEuint64(uint64) | InEuint64 |
createInEuint128(uint128) | InEuint128 |
createInEaddress(address) | InEaddress |
All produce signed EncryptedInput shapes signed for account().
Decrypt
| Function | Returns | Notes |
|---|
decryptForTx_withoutPermit(bytes32 ctHash) | (bytes32, uint256, bytes) | (ctHash, plaintext, signature). Signature consumable by FHE.publishDecryptResult. Requires FHE.allowPublic(handle) to have been called. |
decryptForTx_withPermit(bytes32 ctHash, Permission permit) | (bytes32, uint256, bytes) | ACL-gated decryptForTx. |
decryptForView(bytes32 ctHash, Permission permit) | uint256 | Off-chain seal/unseal. Reverts on deny — to assert deny use mockThresholdNetwork.querySealOutput(...). |
Permits
| Function | Description |
|---|
permit_createSelf() | Self-permit for the connected account; sealing key auto-derived. |
permit_createShared(address recipient) | Issuer-side shared permit. |
permit_exportShared(Permission perm) | Strip sensitive fields → SharedPermitExport. |
permit_importShared(SharedPermitExport export) | Recipient-side completion. Reverts unless export.recipient == account(). |
createSealingKey(bytes32 seed) | Custom sealing key (rarely needed). |
Mock storage layout
MockTaskManager.mockStorage is the on-chain plaintext storage that backs getPlaintext / expectPlaintext. It only exists in the mock environment — getPlaintext reverts on real CoFHE networks.
foundry.toml requirements
[profile.default]
solc_version = "0.8.25" # cofhe-contracts target
evm_version = "cancun" # MockACL uses tstore/tload
auto_detect_remappings = false
code_size_limit = 100000 # mocks exceed 24 KB
libs = ["node_modules"]
remappings.txt (canonical shape)
forge-std/=node_modules/forge-std/src/
hardhat/=node_modules/forge-std/src/
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@fhenixprotocol/cofhe-contracts/=node_modules/@fhenixprotocol/cofhe-contracts/
@cofhe/mock-contracts/=node_modules/@cofhe/mock-contracts/
@cofhe/foundry-plugin/=node_modules/@cofhe/foundry-plugin/
@cofhe/mock-contracts/ points at the package root, not …/contracts/. The plugin’s imports include the contracts/ segment themselves.
hardhat/=node_modules/forge-std/src/ is required so that MockCoFHE.sol’s import "hardhat/console.sol" resolves to forge-std’s compatible console.
Version pinning
@cofhe/foundry-plugin and @cofhe/mock-contracts pin @fhenixprotocol/cofhe-contracts exactly — keep all three CoFHE packages aligned. Known-good tuple as of the latest release:
| Package | Version |
|---|
@cofhe/foundry-plugin | 0.5.1 |
@cofhe/mock-contracts | 0.5.1 |
@fhenixprotocol/cofhe-contracts | 0.1.3 |
See the Compatibility page for the canonical table.