Skip to main content
This page covers the “encrypt → write tx” flow: encrypt plaintext values into InE* structs and pass them directly into a contract call. encryptInputs returns EncryptedItemInput objects that match the Solidity InE* input structs. The on-chain CoFHE library validates the verifier signature before the contract can use the ciphertext.

Flow

  1. Ensure your contract function accepts encrypted InE* parameters.
  2. Encrypt the plaintext values with encryptInputs.
  3. Send a transaction and pass the encrypted structs as the InE* arguments.

Prerequisites

  1. Create and connect a client.
  2. Your contract function must accept encrypted InE* structs.
The encrypted type you choose in TypeScript must match the Solidity parameter type:
  • Encryptable.uint32(...)InEuint32
  • Encryptable.bool(...)InEbool
  • Encryptable.address(...)InEaddress

Example: encrypt and call a contract

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

import '@fhenixprotocol/cofhe-contracts/FHE.sol';

contract EncryptedCounter {
  euint32 public count;

  function setCount(InEuint32 memory _inCount) external {
    count = FHE.asEuint32(_inCount);
    FHE.allowThis(count);
    FHE.allowSender(count);
  }
}

Common pitfalls

  • Wrong Encryptable type: the Encryptable.* factory must match the Solidity parameter type (InEuint32 vs InEuint64, etc).
  • Wrong account / chain: encrypted inputs are authorized for a specific account + chainId. If you encrypt under the wrong wallet/network, the contract call may revert.
  • ABI struct shape mismatch: if you hand-write an ABI, ensure the tuple fields are (ctHash, securityZone, utype, signature) in the same order your client library expects.