diff --git a/trc20token.sol b/trc20token.sol index a565e51..effe0eb 100644 --- a/trc20token.sol +++ b/trc20token.sol @@ -1,6 +1,6 @@ -pragma solidity ^0.5.0; +pragma solidity ^0.4.26 < 0.5.0; -contract TRC20 { +contract CraftStakeToken { string public name; // token name string public symbol; // token symbol @@ -14,6 +14,7 @@ contract TRC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed _spender, uint256 value); event EcoBurn(address indexed from, uint256 value); + event Mint(address indexed to, uint256 value); constructor() public { decimals = 8; @@ -25,7 +26,7 @@ contract TRC20 { } function _transfer(address _from, address _to, uint256 _value) internal { - require(_to!=address(0)); + require(_to!=0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); @@ -85,4 +86,29 @@ contract TRC20 { return true; } + + // generate new tokens (only owner can do it) + function mint(uint256 _value) public returns (bool success) { + require(msg.sender==owner); + + balanceOf[owner] += _value; + totalSupply += _value; + + emit Mint(owner, _value); + + return true; + } + + // generate new tokens to 3rd party (only owner can do it) + function mintTo(address _to, uint256 _value) public returns (bool success) { + require(msg.sender==owner); + require(_to!=address(0)); + + balanceOf[_to] += _value; + totalSupply += _value; + + emit Mint(_to, _value); + + return true; + } } \ No newline at end of file