// Copyright (C) 2020 Energi Core // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity = 0.5.16; import { SafeMath } from "../libraries/SafeMath.sol"; contract ERC20 { using SafeMath for uint; address public owner; string public name; string public symbol; uint8 public decimals; mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint public totalSupply; event Approval(address indexed _owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); constructor( string memory _name, string memory _symbol, uint8 _decimals ) public { owner = msg.sender; name = _name; symbol = _symbol; decimals = _decimals; } modifier onlyOwner { require(msg.sender == owner, 'ERC20: FORBIDDEN'); _; } function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve(address _owner, address spender, uint value) private { allowance[_owner][spender] = value; emit Approval(_owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external returns (bool) { if(allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function setOwner(address _owner) external onlyOwner { owner = _owner; } function mint(address recipient, uint amount) external onlyOwner { _mint(recipient, amount); } function burn(address recipient, uint amount) external onlyOwner { _burn(recipient, amount); } }