Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/sdk-guides/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ contract MyContract {
}
```

> Important: Functions that call `FHE.fromExternal()` or other FHE operators such as `FHE.add()` cannot be marked as `view`.
> These operations trigger proof verification / FHE execution under the hood, so they must be executed as regular state-changing calls rather than read-only `eth_call` view functions.

With `my_contract` the contract in question using `ethers` it is possible to call the add function as following.

```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ FHE.fromExternal(inputEuint32, inputProof);

This method verifies the zero-knowledge proof and returns a usable encrypted value within the contract.

{% hint style="warning" %}
Functions using `FHE.fromExternal()` should not be marked as `view`.

Although this does not mutate your application-level contract state, the proof verification step is not compatible with Solidity's `view` modifier. Keep these functions as regular state-changing functions.
{% endhint %}

#### Replace

```solidity
Expand Down
6 changes: 6 additions & 0 deletions docs/solidity-guides/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ function transfer(
2. **Type conversion**:\
The function transforms `externalEbool`, `externalEaddress`, `externalEuintXX` into the appropriate encrypted type (`ebool`, `eaddress`, `euintXX`) for further operations within the contract.

{% hint style="warning" %}
Functions that call `FHE.fromExternal()` cannot be marked as `view`.

Even if your contract logic feels read-only, `FHE.fromExternal()` performs proof verification under the hood, which makes the call incompatible with Solidity's `view` modifier. Declare these functions as regular state-changing functions and invoke them as transactions.
{% endhint %}

## Best Practices

- **Input packing**: Minimize the size and complexity of zero-knowledge proofs by packing all encrypted inputs into a single ciphertext.
Expand Down