@@ -4,43 +4,17 @@ pragma solidity ^0.8.24;
44
55import "fhevm/lib/TFHE.sol " ;
66import "fhevm/config/ZamaFHEVMConfig.sol " ;
7- import "fhevm/config/ZamaGatewayConfig.sol " ;
8- import "fhevm/gateway/GatewayCaller.sol " ;
9- import "fhevm-contracts/contracts/token/ERC20/extensions/ConfidentialERC20Mintable.sol " ;
7+ import "fhevm-contracts/contracts/token/ERC20/extensions/ConfidentialERC20WithErrorsMintable.sol " ;
108
119/// @notice This contract implements an encrypted ERC20-like token with confidential balances using Zama's FHE library.
1210/// @dev It supports typical ERC20 functionality such as transferring tokens, minting, and setting allowances,
1311/// @dev but uses encrypted data types.
14- contract MyConfidentialERC20 is
15- SepoliaZamaFHEVMConfig ,
16- SepoliaZamaGatewayConfig ,
17- GatewayCaller ,
18- ConfidentialERC20Mintable
19- {
20- // @note `SECRET` is not so secret, since it is trivially encrypted and just to have a decryption test
21- euint64 internal immutable SECRET;
22-
23- // @note `revealedSecret` will hold the decrypted result once the Gateway will relay the decryption of `SECRET`
24- uint64 public revealedSecret;
25-
12+ contract MyConfidentialERC20 is SepoliaZamaFHEVMConfig , ConfidentialERC20WithErrorsMintable {
2613 /// @notice Constructor to initialize the token's name and symbol, and set up the owner
2714 /// @param name_ The name of the token
2815 /// @param symbol_ The symbol of the token
29- constructor (string memory name_ , string memory symbol_ ) ConfidentialERC20Mintable (name_, symbol_, msg .sender ) {
30- SECRET = TFHE.asEuint64 (42 );
31- TFHE.allowThis (SECRET);
32- }
33-
34- /// @notice Request decryption of `SECRET`
35- function requestSecret () public {
36- uint256 [] memory cts = new uint256 [](1 );
37- cts[0 ] = Gateway.toUint256 (SECRET);
38- Gateway.requestDecryption (cts, this .callbackSecret.selector , 0 , block .timestamp + 100 , false );
39- }
40-
41- /// @notice Callback function for `SECRET` decryption
42- /// @param `decryptedValue` The decrypted 64-bit unsigned integer
43- function callbackSecret (uint256 , uint64 decryptedValue ) public onlyGateway {
44- revealedSecret = decryptedValue;
45- }
16+ constructor (
17+ string memory name_ ,
18+ string memory symbol_
19+ ) ConfidentialERC20WithErrorsMintable (name_, symbol_, msg .sender ) {}
4620}
0 commit comments