Skip to main content
The mock MockTaskManager can print every FHE operation it runs. Under Hardhat 3 this logging is off until you turn it on, so wrap the code you want to inspect in withLogs.

What gets logged

Each FHE operation prints one line with the operation name, its inputs, and its result. Each handle is shortened and followed, in brackets, by the plaintext the mock stores for it:

Log one block with withLogs

cofhe.mocks.withLogs(name, fn) turns logging on, runs fn, and prints name as the header of the block:
When fn returns or throws, withLogs closes the block and turns logging back off if it was off before.

Turn logging on and off

enableLogs(label?) and disableLogs() leave logging on across several calls:
The optional label prints a header immediately, so you can find the section in the output.

Why logging starts off

The logging switch is the logOps flag in MockTaskManager storage. The contract declares it true, but that default is set by the constructor. The plugin places MockTaskManager with hardhat_setCode, which skips the constructor, so the flag starts as false on every new connection. Because the flag lives onchain, each helper above is a transaction on the current chain, and every new connection starts with logging off again.
The config type accepts cofhe.logMocks, but no plugin code reads it. Setting it to true does not turn logging on.
The cofhe:set-log-ops task also flips the flag, but it opens a connection of its own. Against the in-process network that is a separate chain, so the task does not affect your tests. Use the helpers above instead.