zama-ai / fhevm-contracts

A standard contract library for the fhEVM ecosystem
Other
4 stars 0 forks source link

Transfer function no longer compatible with latest library. #42

Open vm06007 opened 3 weeks ago

vm06007 commented 3 weeks ago

https://github.com/zama-ai/fhevm-contracts/blob/7bfbfda98541d02e9c4ccc8c74354eb00e9ea178/contracts/token/ERC20/EncryptedERC20.sol#L68

This no longer works with fhevm/lib/TFHE.sol function signature seems to be different and does not work with example in Zama Remix as well

Screenshot 2024-06-22 at 4 33 41 PM

vm06007 commented 3 weeks ago

As a result now your basic example simply won't work Screenshot 2024-06-22 at 4 38 18 PM

vm06007 commented 3 weeks ago

@jatZama can you take a look?

immortal-tofu commented 3 weeks ago

Hi @vm06007 ! The issue you're experiencing arises because Remix does not respect the dependency versions specified in the package.json file. When you use the fhevm-contracts package in Remix, it defaults to using the latest version of fhevm, which is 0.5.0, regardless of the version declared in package.json. fhevm-contracts has not been updated and is still using fhevm 0.4.0.

If you want to use fhevm-contracts with fhEVM 0.4.0, we advise you to use our hardhat template which is still on 0.4.0.

Since we just released fhEVM 0.5.0, and will do many updates in the coming days, I'd suggest you continue on 0.4.0 in the meantime, using hardhat template.

vm06007 commented 3 weeks ago

Hi @vm06007 ! The issue you're experiencing arises because Remix does not respect the dependency versions specified in the package.json file. When you use the fhevm-contracts package in Remix, it defaults to using the latest version of fhevm, which is 0.5.0, regardless of the version declared in package.json. fhevm-contracts has not been updated and is still using fhevm 0.4.0.

If you want to use fhevm-contracts with fhEVM 0.4.0, we advise you to use our hardhat template which is still on 0.4.0.

Since we just released fhEVM 0.5.0, and will do many updates in the coming days, I'd suggest you continue on 0.4.0 in the meantime, using hardhat template.

I don't control which package.json is used for https://remix.zama.ai/ I'm hoping ZAMA team can fix it so anyone can open Zama Remix and try out all examples or at least play with Zama Network accordingly to all tutorials and updates that just keep coming.

jatZama commented 3 weeks ago

We will fix everything related to Remix and fhevm-contracts so they will be compatible with new fhevm release next week, this was a major release compared to previous ones since we revamped the whole stack. Thank you for your understanding.

vm06007 commented 3 weeks ago

Thanks! Looking forward to stable library version

jatZama commented 3 weeks ago

If it is urgent and you really need to use Remix instead of hardhat, meanwhile I found a temporary fix: Change first import line :

// SPDX-License-Identifier: BSD-3-Clause-Clear

pragma solidity ^0.8.20;

import "fhevm@0.4.0/lib/TFHE.sol";
import "fhevm-contracts/contracts/token/ERC20/EncryptedERC20.sol";

contract MyERC20 is EncryptedERC20 {
  constructor() EncryptedERC20("MyToken", "MYTOKEN") {
    _mint(1000000, msg.sender);
  }
}

Remove .deps/ folder then save file, this will download both fhevm@0.4.0/ and fhevm/ folders inside .deps/npm/ directory. Now remove fhevm/ and rename the fhevm@0.4.0/folder to fhevm/. Finally remove the @0.4.0 from first import in Solidity, now you should be able to compile the ERC20 contract in Remix.

vm06007 commented 3 weeks ago

If it is urgent and you really need to use Remix instead of hardhat, meanwhile I found a temporary fix: Change first import line :

// SPDX-License-Identifier: BSD-3-Clause-Clear

pragma solidity ^0.8.20;

import "fhevm@0.4.0/lib/TFHE.sol";
import "fhevm-contracts/contracts/token/ERC20/EncryptedERC20.sol";

contract MyERC20 is EncryptedERC20 {
  constructor() EncryptedERC20("MyToken", "MYTOKEN") {
    _mint(1000000, msg.sender);
  }
}

Remove .deps/ folder then save file, this will download both fhevm@0.4.0/ and fhevm/ folders inside .deps/npm/ directory. Now remove fhevm/ and rename the fhevm@0.4.0/folder to fhevm/. Finally remove the @0.4.0 from first import in Solidity, now you should be able to compile the ERC20 contract in Remix.

Or as was suggested can also just do "Clone Workspace" from https://github.com/zama-ai/fhevm-hardhat-template And then it also simply works (just need to specify github username/email that comes a bit inconvenient)

Screenshot 2024-06-22 at 10 15 53 PM

jatZama commented 3 weeks ago

AH yes good catch, this is way simpler. I did not know it was possible to create a new workspace from an existing Git repo.