Config files for my GitHub profile. // SPDX-License-Identifier: MIT pragma solidity ^0.8.20;
// Import Zama's base contract for an encrypted ERC20 token import "@zama-ai/fhevm-contracts/contracts/token/erc20/EncryptedERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol";
/**
-
@title MyConfidentialToken
-
@dev A confidential token where balances are encrypted using FHE.
-
inherits from Zama's EncryptedERC20 and OpenZeppelin's Ownable. / contract MyConfidentialToken is EncryptedERC20, Ownable { /*
- @dev Sets the name and symbol for the token, and the initial owner. */ constructor( string memory name, string memory symbol ) EncryptedERC20(name, symbol) Ownable(msg.sender) {}
/**
- @dev Creates
amounttokens and assigns them tomsg.sender. - Only the owner of the contract can call this function.
- The amount is minted as a public value but stored as an encrypted balance. */ function mint(uint256 amount) public onlyOwner { // The _mint function is inherited from EncryptedERC20 and handles // the encryption of the balance automatically. _mint(msg.sender, amount); }
/**
-
@dev Overrides the transfer function to use FHE for confidential transactions.
-
The
euint32type represents an encrypted 32-bit unsigned integer. */ function transfer(address to, bytes calldata encryptedAmount) public override returns (bool) { // Decrypt the transaction amount on-chain using FHE uint32 amount = TFHE.decrypt(encryptedAmount);// Call the internal transfer function with the decrypted amount _transfer(msg.sender, to, amount);
return true; } }