pragma solidity ^0.4.24;
/**
* Math operations with safety checks
*/
contract SafeMath {
function mul(uint256 _a, uint256 _b) internal pure returns (uint256){
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
assert(c / _a == _b);
return c;
}
function div(uint256 _a, uint256 _b) internal pure returns (uint256){
uint256 c = _a / _b;
// assert(b > 0); // Solidity automatically throws when dividing by 0
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 _a, uint256 _b) internal pure returns (uint256){
assert(_b <= _a);
return _a - _b;
}
function add(uint256 _a,uint256 _b) internal pure returns (uint256){
uint256 c = _a + _b;
assert(c >= _a);
return c;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor () public{
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(
address _newOwner
)
onlyOwner
public
{
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
contract ERC20StdToken is Ownable, SafeMath {
uint256 public totalSupply;
string public name;
uint8 public decimals;
string public symbol;
bool public isMint; // 是否可增发
bool public isBurn; // 是否可销毁
bool public isFreeze; // 是否可冻结
mapping (address => uint256) public balanceOf;
mapping (address => uint256) public freezeOf;
mapping (address => mapping (address => uint256)) public allowance;
constructor(
address _owner,
string _name,
string _symbol,
uint8 _decimals,
uint256 _initialSupply,
bool _isMint,
bool _isBurn,
bool _isFreeze) public {
require(_owner != address(0));
owner = _owner;
decimals = _decimals;
symbol = _symbol;
name = _name;
isMint = _isMint;
isBurn = _isBurn;
isFreeze = _isFreeze;
totalSupply = _initialSupply * 10 ** uint256(decimals);
balanceOf[_owner] = totalSupply;
}
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
/* This notifies clients about the amount burnt */
event Burn(address indexed _from, uint256 value);
/* This notifies clients about the amount frozen */
event Freeze(address indexed _from, uint256 value);
/* This notifies clients about the amount unfrozen */
event Unfreeze(address indexed _from, uint256 value);
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
success = true;
}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != 0);
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
// balanceOf[msg.sender] -= _value;
balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value);
// balanceOf[_to] += _value;
balanceOf[_to] = SafeMath.add(balanceOf[_to], _value);
emit Transfer(msg.sender, _to, _value);
success = true;
}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != 0);
require(balanceOf[_from] >= _value);
require(allowance[_from][msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
// balanceOf[_from] -= _value;
balanceOf[_from] = SafeMath.sub(balanceOf[_from], _value);
// balanceOf[_to] += _value;
balanceOf[_to] = SafeMath.add(balanceOf[_to], _value);
// allowance[_from][msg.sender] -= _value;
allowance[_from][msg.sender] = SafeMath.sub(allowance[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
success = true;
}
function mint(uint256 amount) onlyOwner public {
require(isMint);
require(amount >= 0);
// balanceOf[msg.sender] += amount;
balanceOf[msg.sender] = SafeMath.add(balanceOf[msg.sender], amount);
// totalSupply += amount;
totalSupply = SafeMath.add(totalSupply, amount);
}
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value > 0);
balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value); // Subtract from the sender
totalSupply = SafeMath.sub(totalSupply, _value); // Updates totalSupply
emit Burn(msg.sender, _value);
success = true;
}
function freeze(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(_value > 0);
balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value); // Subtract from the sender
freezeOf[msg.sender] = SafeMath.add(freezeOf[msg.sender], _value); // Updates totalSupply
emit Freeze(msg.sender, _value);
success = true;
}
function unfreeze(uint256 _value) public returns (bool success) {
require(freezeOf[msg.sender] >= _value); // Check if the sender has enough
require(_value > 0);
freezeOf[msg.sender] = SafeMath.sub(freezeOf[msg.sender], _value); // Subtract from the sender
balanceOf[msg.sender] = SafeMath.add(balanceOf[msg.sender], _value);
emit Unfreeze(msg.sender, _value);
success = true;
}
}
{
"compilationTarget": {
"ERC20StdToken.sol": "ERC20StdToken"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isBurn","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isMint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"unfreeze","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isFreeze","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"freezeOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"freeze","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_owner","type":"address"},{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint8"},{"name":"_initialSupply","type":"uint256"},{"name":"_isMint","type":"bool"},{"name":"_isBurn","type":"bool"},{"name":"_isFreeze","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Freeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Unfreeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]