Skip to content

Commit 7e388a6

Browse files
committed
docs: clarify fromExternal view limitations
1 parent 02f6cc0 commit 7e388a6

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

docs/sdk-guides/input.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ contract MyContract {
4545
}
4646
```
4747

48+
> Important: Functions that call `FHE.fromExternal()` or other FHE operators such as `FHE.add()` cannot be marked as `view`.
49+
> 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.
50+
4851
With `my_contract` the contract in question using `ethers` it is possible to call the add function as following.
4952

5053
```js

docs/solidity-guides/getting-started/quick-start-tutorial/turn_it_into_fhevm.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ FHE.fromExternal(inputEuint32, inputProof);
220220

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

223+
{% hint style="warning" %}
224+
Functions using `FHE.fromExternal()` should not be marked as `view`.
225+
226+
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.
227+
{% endhint %}
228+
223229
#### Replace
224230

225231
```solidity

docs/solidity-guides/inputs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ function transfer(
127127
2. **Type conversion**:\
128128
The function transforms `externalEbool`, `externalEaddress`, `externalEuintXX` into the appropriate encrypted type (`ebool`, `eaddress`, `euintXX`) for further operations within the contract.
129129

130+
{% hint style="warning" %}
131+
Functions that call `FHE.fromExternal()` cannot be marked as `view`.
132+
133+
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.
134+
{% endhint %}
135+
130136
## Best Practices
131137

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

0 commit comments

Comments
 (0)