From 00d77cda01e856dca7f9bb82e3436292c1b5bd3a Mon Sep 17 00:00:00 2001 From: 0xb337r007 <0xe4e5@proton.me> Date: Mon, 12 Jun 2023 13:24:47 +0200 Subject: [PATCH] add CommunityERC20 --- contracts/mvp/CommunityERC20.sol | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 contracts/mvp/CommunityERC20.sol diff --git a/contracts/mvp/CommunityERC20.sol b/contracts/mvp/CommunityERC20.sol new file mode 100644 index 0000000..d674722 --- /dev/null +++ b/contracts/mvp/CommunityERC20.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: Mozilla Public License 2.0 +pragma solidity ^0.8.17; + +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts/utils/Context.sol"; + +contract CommunityERC20 is + Context, + Ownable, + ERC20 +{ + /** + * If we want unlimited total supply we should set maxSupply to 2^256-1. + */ + uint256 public maxSupply; + + constructor( + string memory _name, + string memory _symbol, + uint256 _maxSupply + ) ERC20(_name, _symbol) { + maxSupply = _maxSupply; + } + + // Events + + // External functions + + function setMaxSupply(uint256 newMaxSupply) external onlyOwner { + require(newMaxSupply >= totalSupply(), "MAX_SUPPLY_LOWER_THAN_TOTAL_SUPPLY"); + maxSupply = newMaxSupply; + } + + /** + * @dev Mint tokens for each address in `addresses` each one with + * an amount specified in `amounts`. + * + */ + function mintTo(address[] memory addresses, uint256[] memory amounts) external onlyOwner { + for (uint256 i = 0; i < addresses.length; i++) { + uint256 amount = amounts[i]; + require(totalSupply() + amount <= maxSupply, "MAX_SUPPLY_REACHED"); + _mint(addresses[i], amount); + } + } + + // Public functions + + // Internal functions + + // Private functions +}