// SPDX-License-Identifier: MIT // File: contracts/ArtKDev.sol import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; pragma solidity ^0.8.17; /** * @title ArtKDev Token * @dev ArtKDev ERC20 Token */ contract ArtKDev is ERC20Burnable, ERC20Capped, Ownable { uint256 public constant MAX_CAP = 1000 * (10**6) * (10**18); // 1 billion uint256 AdminsAmount; address public Governance; mapping(address => bool) public Admins; event TokenRecovered( address indexed token, address indexed destination, uint256 indexed amount ); event AdminAdded(address indexed newAdmin); event AdminRemoved(address indexed oldAdmin); modifier onlyGovernance() { require(msg.sender == Governance, "You are not a governance"); _; } modifier onlyAdmin() { uint256 counter = 0; for (uint256 i = 0; i < AdminsAmount; i++) { if (Admins[msg.sender] == true) { counter++; break; } } require(counter > 0, "You are not an admin"); _; } constructor(address[] memory _admins) ERC20("ArtKDev", "AKD") ERC20Capped(1000000000 * 10**18) { for (uint256 i = 0; i < _admins.length; i++) { require(_admins[i] != address(0), "Invalid admin address"); Admins[_admins[i]] = true; } AdminsAmount++; Governance = msg.sender; Admins[msg.sender] = true; _mint(Governance, (MAX_CAP * 20) / 100); } /** * @dev See {ERC20-_mint}. */ function _mint(address _account, uint256 _amount) internal virtual override(ERC20, ERC20Capped) { require( ERC20.totalSupply() + _amount <= cap(), "ERC20Capped: cap exceeded" ); super._mint(_account, _amount); } /** * @dev See {ERC20-_mint}. */ function Mint(address _account, uint256 _amount) external onlyAdmin { _mint(_account, _amount); } /** * @notice Function to set governance contract * Owner is assumed to be governance * @param _governance Address of governance contract */ function SetGovernance(address _governance) external onlyOwner { Governance = _governance; } function AddAdmin(address _admin) external onlyOwner { require(_admin != address(0), "Admin address must be not zero"); require(Admins[_admin] == false, "You are already an admin"); Admins[_admin] = true; AdminsAmount++; emit AdminAdded(_admin); } function RemoveAdmin(address _admin) external onlyOwner { require(_admin != address(0), "Admin address must be not zero"); require(Admins[_admin] == true, "You are not an admin already"); Admins[_admin] = false; AdminsAmount--; emit AdminRemoved(_admin); } /** * @notice Function to recover funds * Owner is assumed to be governance or ARTKDEV trusted party for helping users * @param _token Address of token to be rescued * @param _destination User address * @param _amount Amount of tokens */ function RecoverToken( address _token, address _destination, uint256 _amount ) external onlyGovernance { require(_token != _destination, "Invalid address"); require( IERC20(_token).transfer(_destination, _amount), "Retrieving failed" ); emit TokenRecovered(_token, _destination, _amount); } }