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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.6.2; import "./ERC20.sol"; import "./ERC20Burnable.sol"; import "./MinterRole.sol"; contract Gala is ERC20("Gala", "GALA"), ERC20Burnable, MinterRole { address public owner; uint256 private _totalMinted; uint256 private _cap; constructor() public { owner = msg.sender; _setupDecimals(8); _cap = 5000000000000000000; } modifier onlyOwner() { require(msg.sender == owner, "caller not owner"); _; } function _mint(address account, uint256 amount) internal override { super._mint(account, amount); _totalMinted = _totalMinted.add(amount); } function cap() public view returns (uint256) { return _cap; } function totalMinted() public view returns (uint256) { return _totalMinted; } function mintBulk(address[] memory accounts, uint256[] memory amounts) public onlyMinter returns (bool) { require(accounts.length == amounts.length, "arrays must have same length"); for (uint256 i = 0; i < accounts.length; i++) { require(amounts[i] > 0, "amount must be greater than 0"); _mint(accounts[i], amounts[i]); } return true; } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // When minting tokens require(totalMinted().add(amount) <= cap(), "ERC20Capped: cap exceeded"); } } function addMinter(address account) public override onlyOwner { _addMinter(account); } function removeMinter(address account) public onlyOwner { _removeMinter(account); } } |