Contract Name:
ERC20Mintable
Contract Source Code:
<i class='far fa-question-circle text-muted ms-2' data-bs-trigger='hover' data-bs-toggle='tooltip' data-bs-html='true' data-bs-title='Click on the check box to select individual contract to compare. Only 1 contract can be selected from each side.'></i>
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.6;
import "SafeOwnable.sol";
contract ERC20Mintable is SafeOwnable {
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
string public name;
string public symbol;
uint8 public immutable decimals;
uint public totalSupply;
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
require(_decimals > 0, "decimals");
}
function transfer(address _recipient, uint _amount) external returns (bool) {
_transfer(msg.sender, _recipient, _amount);
return true;
}
function approve(address _spender, uint _amount) external returns (bool) {
_approve(msg.sender, _spender, _amount);
return true;
}
function increaseAllowance(address _spender, uint _amount) external returns (bool) {
_approve(msg.sender, _spender, allowance[msg.sender][_spender] + _amount);
return true;
}
function decreaseAllowance(address _spender, uint256 _amount) external returns (bool) {
_approve(msg.sender, _spender, allowance[msg.sender][_spender] - _amount);
return true;
}
function transferFrom(address _sender, address _recipient, uint _amount) external returns (bool) {
require(allowance[_sender][msg.sender] >= _amount, "ERC20: insufficient approval");
_transfer(_sender, _recipient, _amount);
_approve(_sender, msg.sender, allowance[_sender][msg.sender] - _amount);
return true;
}
function mint(address _account, uint _amount) external onlyOwner {
_mint(_account, _amount);
}
function burn(address _account, uint _amount) external onlyOwner {
_burn(_account, _amount);
}
function _transfer(address _sender, address _recipient, uint _amount) internal {
require(_sender != address(0), "ERC20: transfer from the zero address");
require(_recipient != address(0), "ERC20: transfer to the zero address");
require(balanceOf[_sender] >= _amount, "ERC20: insufficient funds");
balanceOf[_sender] -= _amount;
balanceOf[_recipient] += _amount;
emit Transfer(_sender, _recipient, _amount);
}
function _mint(address _account, uint _amount) internal {
require(_account != address(0), "ERC20: mint to the zero address");
totalSupply += _amount;
balanceOf[_account] += _amount;
emit Transfer(address(0), _account, _amount);
}
function _burn(address _account, uint _amount) internal {
require(_account != address(0), "ERC20: burn from the zero address");
balanceOf[_account] -= _amount;
totalSupply -= _amount;
emit Transfer(_account, address(0), _amount);
}
function _approve(address _owner, address _spender, uint _amount) internal {
require(_owner != address(0), "ERC20: approve from the zero address");
require(_spender != address(0), "ERC20: approve to the zero address");
allowance[_owner][_spender] = _amount;
emit Approval(_owner, _spender, _amount);
}
} <i class='far fa-question-circle text-muted ms-2' data-bs-trigger='hover' data-bs-toggle='tooltip' data-bs-html='true' data-bs-title='Click on the check box to select individual contract to compare. Only 1 contract can be selected from each side.'></i>
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.6;
import "IOwnable.sol";
contract SafeOwnable is IOwnable {
uint public constant RENOUNCE_TIMEOUT = 1 hours;
address public override owner;
address public pendingOwner;
uint public renouncedAt;
event OwnershipTransferInitiated(address indexed previousOwner, address indexed newOwner);
event OwnershipTransferConfirmed(address indexed previousOwner, address indexed newOwner);
constructor() {
owner = msg.sender;
emit OwnershipTransferConfirmed(address(0), msg.sender);
}
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
function isOwner() public view returns (bool) {
return msg.sender == owner;
}
function transferOwnership(address _newOwner) external override onlyOwner {
require(_newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferInitiated(owner, _newOwner);
pendingOwner = _newOwner;
}
function acceptOwnership() external override {
require(msg.sender == pendingOwner, "Ownable: caller is not pending owner");
emit OwnershipTransferConfirmed(msg.sender, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
function initiateRenounceOwnership() external onlyOwner {
require(renouncedAt == 0, "Ownable: already initiated");
renouncedAt = block.timestamp;
}
function acceptRenounceOwnership() external onlyOwner {
require(renouncedAt > 0, "Ownable: not initiated");
require(block.timestamp - renouncedAt > RENOUNCE_TIMEOUT, "Ownable: too early");
owner = address(0);
pendingOwner = address(0);
renouncedAt = 0;
}
function cancelRenounceOwnership() external onlyOwner {
require(renouncedAt > 0, "Ownable: not initiated");
renouncedAt = 0;
}
} <i class='far fa-question-circle text-muted ms-2' data-bs-trigger='hover' data-bs-toggle='tooltip' data-bs-html='true' data-bs-title='Click on the check box to select individual contract to compare. Only 1 contract can be selected from each side.'></i>
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.6;
interface IOwnable {
function owner() external view returns(address);
function transferOwnership(address _newOwner) external;
function acceptOwnership() external;
}