Skip to main content
This page covers the “encrypt to write tx” flow: encrypt plaintext values and pass them straight into a contract call. encryptInputs returns one ciphertext handle per value, followed by a single signature covering the batch. Each handle is an externalEuintXX, and the signature is the bytes proof that follows it in the function signature. The onchain CoFHE library verifies the proof before the contract can use the ciphertext.

Flow

  1. Ensure your contract function accepts an externalEuintXX handle plus a bytes proof.
  2. Encrypt the plaintext values with encryptInputs, naming the contract that will consume them.
  3. Send a transaction, passing the handle and the proof.

Prerequisites

  1. Create and connect a client.
  2. Your contract function must accept externalEuintXX parameters with a bytes proof.
The encrypted type you choose in TypeScript must match the Solidity parameter type:
  • Encryptable.uint32(...) to externalEuint32
  • Encryptable.bool(...) to externalEbool
  • Encryptable.address(...) to externalEaddress

Example: encrypt and call a contract

Common pitfalls

  • Wrong Encryptable type: the factory must match the Solidity parameter, externalEuint32 against externalEuint64.
  • 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.
  • Stale ABI shape: the old (ctHash, securityZone, utype, signature) tuple is gone. A hand-written ABI takes bytes32 for the handle and bytes for the proof.
  • Missing or wrong consuming contract: name the contract that runs FHE.asEuint*. Getting it wrong compiles and reverts at runtime.