Creating the contract
Import Required Libraries/Contracts
Defining the Confidential ERC20 Contract
Our confidential ERC20 contract will implement the Ownable2Step
contract from OpenZeppelin and the GatewayCaller
library to enable decryption calls via the Gateway. The Ownable2Step
contract sets the owner in the constructor, allowing only the owner to view all users’ balances.
State variables:
We want our balances to be encrypted so we define a mapping of the address to an euint64 data type. Initialize state variables for total supply, balances, and allowances using encrypted integers (e.g., euint64
for balances)
Events:
The events are the same as in a standard ERC20 contract.
Last updated