Created
November 27, 2017 20:37
-
-
Save Shigawire/0dddb06e8f0e87e12885fd005adaf10d to your computer and use it in GitHub Desktop.
ECTSToken Solidity Contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//lock to 0.4.18 <= compiler version < 0.5 | |
pragma solidity^0.4.18; | |
import "./ERC20.sol"; | |
contract ECTSToken is ERC20 { | |
string public constant name = 'ECTS Token'; | |
string public constant symbol = 'ECTS'; | |
uint8 public constant decimals = 0; | |
uint256 public totalSupply = 0; | |
address public owner; | |
mapping (address => mapping (address => uint256)) allowed; | |
mapping (address => uint256) public balanceOf; | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
function ECTSToken() public { | |
owner = msg.sender; | |
balanceOf[owner] = totalSupply; | |
} | |
function totalSupply() constant public returns (uint256 _totalSupply) { | |
_totalSupply = totalSupply; | |
} | |
function balanceOf(address _owner) constant public returns (uint256 balance) { | |
return balanceOf[_owner]; | |
} | |
function approve(address _spender, uint256 _value) public returns (bool success) { | |
allowed[msg.sender][_spender] = _value; | |
Approval(msg.sender, _spender, _value); | |
success = true; | |
} | |
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { | |
return allowed[_owner][_spender]; | |
} | |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { | |
require(_to != 0x0); | |
require(balanceOf[_from] >= _value); | |
require(balanceOf[_to] + _value >= balanceOf[_to]); | |
require(allowed[_from][msg.sender] >= _value); | |
balanceOf[_to] +=_value; | |
balanceOf[_from] -= _value; | |
allowed[_from][msg.sender] -= _value; | |
Transfer(_from, _to, _value); | |
success = true; | |
} | |
function transfer(address _to, uint256 _value) public returns (bool success) { | |
require(balanceOf[msg.sender] > _value); | |
require(balanceOf[_to] + _value > balanceOf[_to]); | |
balanceOf[msg.sender] -= _value; | |
balanceOf[_to] += _value; | |
success = true; | |
} | |
function mintTokens(uint256 _tokens) public onlyOwner { | |
totalSupply += _tokens; | |
balanceOf[owner] += _tokens; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment