Bug
The code example in Debug-Logging.md has three errors that prevent it from compiling:
contract EncryptedNumberContract {
using EncryptedNumberLibrary for EncryptedNumber; // ❌ #1: doesn't exist
function computeWithEncryptedNumbers(inEuint64 encryptedA, inEuint64 encryptedB) public {
euint64 result = FHE.asEuint64(encryptedA) + FHE.asEuint64(encryptedB);
uint256 debug_Result = FHE.decrypt(result);
Console.log(result); // ❌ #2: passes euint64 to Console.log(int256)
euint64 finalResult = result * FHE.asEuint64(encryptedA);
return finalResult; // ❌ #3: function has no return type
}
}
Error 1
EncryptedNumberLibrary and EncryptedNumber do not exist in @fhenixprotocol/contracts. This is a fictional type that was never defined.
Error 2
Console.log accepts int256 or bytes. Passing euint64 (a value type wrapping uint256) logs the ciphertext handle, not the decrypted value. The example likely intends to log debug_Result (the already-decrypted value).
Error 3
The function has no declared return type but contains return finalResult.
Fix
import { Console } from "@fhenixprotocol/contracts/utils/debug/Console.sol";
import { FHE, euint64, inEuint64 } from "@fhenixprotocol/contracts/FHE.sol";
contract EncryptedNumberContract {
function computeWithEncryptedNumbers(inEuint64 calldata encryptedA, inEuint64 calldata encryptedB) public {
euint64 result = FHE.asEuint64(encryptedA) + FHE.asEuint64(encryptedB);
uint256 debug_Result = FHE.decrypt(result);
Console.log(int256(debug_Result)); // log the plaintext
euint64 finalResult = result * FHE.asEuint64(encryptedA);
// no return — function is void
}
}
Files affected
docs/devdocs/Writing Smart Contracts/Debug-Logging.md
Bug
The code example in
Debug-Logging.mdhas three errors that prevent it from compiling:Error 1
EncryptedNumberLibraryandEncryptedNumberdo not exist in@fhenixprotocol/contracts. This is a fictional type that was never defined.Error 2
Console.logacceptsint256orbytes. Passingeuint64(a value type wrappinguint256) logs the ciphertext handle, not the decrypted value. The example likely intends to logdebug_Result(the already-decrypted value).Error 3
The function has no declared return type but contains
return finalResult.Fix
Files affected
docs/devdocs/Writing Smart Contracts/Debug-Logging.md