Skip to content

Docs: Debug-Logging.md example references non-existent EncryptedNumberLibrary, has invalid return statement, and wrong Console.log usage #80

Description

@Sertug17

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions