-
Notifications
You must be signed in to change notification settings - Fork 2
/
ConfidentialERC20Mintable.sol
44 lines (39 loc) · 1.61 KB
/
ConfidentialERC20Mintable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;
import "fhevm/lib/TFHE.sol";
import { Ownable2Step, Ownable } from "@openzeppelin/contracts/access/Ownable2Step.sol";
import { ConfidentialERC20 } from "../ConfidentialERC20.sol";
/**
* @title ConfidentialERC20Mintable
* @notice This contract inherits ConfidentialERC20.
* @dev It allows an owner to mint tokens. Mint amounts are public.
*/
abstract contract ConfidentialERC20Mintable is Ownable2Step, ConfidentialERC20 {
/**
* @notice Emitted when `amount` tokens are minted to one account (`to`).
*/
event Mint(address indexed to, uint64 amount);
/**
* @param name_ Name of the token.
* @param symbol_ Symbol.
* @param owner_ Owner address.
*/
constructor(
string memory name_,
string memory symbol_,
address owner_
) Ownable(owner_) ConfidentialERC20(name_, symbol_) {}
/**
* @notice Mint tokens.
* @param to Address to mint tokens to.
* @param amount Amount of tokens to mint.
*/
function mint(address to, uint64 amount) public virtual onlyOwner {
_unsafeMint(to, amount);
/// @dev Since _totalSupply is not encrypted and we ensure there is no underflow/overflow of encrypted balances
/// during transfers, making _totalSupply invariant during transfers, we know _totalSupply is greater than
/// all individual balances. Hence, the next line forbids any overflow to happen in the _unsafeMint above.
_totalSupply = _totalSupply + amount;
emit Mint(to, amount);
}
}