Broken Encrypted ERC20 contract

Hi,
(I’m sorry for the crappy look of this post but as a new user, I cannot post links or images)

I was playing around with Zama’s testnet and I tried to deploy an encrypted ERC20 from this file
github /zama-ai/fhevm/blob/main/examples/EncryptedERC20.sol
I’m using remix with Zama’s custom plugin.
I can deploy the contract and call decimals(); name(); owner(); pendingOwner(); symbol() and decimals().
I can even transfer, accept and renounce ownership.
For some reason every function implementing FHE logic fails.
When calling the contract function from Zama’s plugin it just display transaction failed, but when calling it the old fashion way from remix “deploy and run transactions” tab, the transactions are pushed to the devnet and reverted.
So I can’t mint any new token and cannot call other functions.
Code is same as github except for that specific line :

import "../lib/TFHE.sol";

Which I replaced by :

import "https://github.com/zama-ai/fhevm/blob/main/lib/TFHE.sol";

In remix in order to import the files correctly.

I even tried by installing the node library using

npm install fhevm

and

npm install fhevm@0.6.0-0

because the first one gave me an outdated version.
This is not working either so I decided to stick to the first attempt setup, the basic remix environment.

What I figured is that somehow remix is pulling some outdated dependencies from node (fhevm-core-contracts/addresses).
Remix pulls the fhevm-core-contracts from npm.
It looks like there are differencies between the addresses of the fhevm github repo and the fhevm-core-contracts on npm.
For example :
ACL address in fhevm-core-contracts is : 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2
On github it’s 0x2Fb4341027eb1d2aD8B5D9708187df8633cAFA92
github /zama-ai/fhevm/blob/release/0.5.x/lib/ACLAddress.sol
and there are others (CoprocessorAddress.sol, FHEPaymentAddress.sol, FHEPaymentAddress.sol etc…).

I’ve tried modifying these addresses but I can’t get it to work. To be honest I don’t know which one is correct. It seems that another user had the same issue withe the Encrypted ERC20 2 days earlier.

Thanks to whoever read that.

The current version is 0.5.0. You shouldn’t use fhevm 0.6.0. The good branch for 0.5.0 GitHub - zama-ai/fhevm at release/0.5.x
main branch is upstream and is a prerelease of 0.6.x.

In Remix, simply type import "fhevm/lib/TFHE.sol"; and it will use the correct version. Otherwise, use the Hardhat template which is configured to run 0.5.x GitHub - zama-ai/fhevm-hardhat-template: fhEVM hardhat template

Thanks for your answer,
unfortunately when I just use import "fhevm/lib/TFHE.sol"; it seems that remix uses a version of TFHE without the setFHEVM() function so I get an undeclared indentifier error.
I honestly don’t really understand what’s wrong or what I am missing.
I had trouble using the hardhat template on windows, so I currently try to just use remix as it’s more beginner friendly.

You took the EncryptedERC20 on main branch. This branch is upstream and will be the 0.6.x.
If you want the EncryptedERC20 usable on 0.5.x, you need to go on release/0.5.x branch :slight_smile: fhevm/examples/EncryptedERC20.sol at release/0.5.x · zama-ai/fhevm · GitHub

It is working well that way, thanks a lot !