Created
July 26, 2018 17:48
-
-
Save fiksn/ffd861cac8e102f4308aae92b22836bf to your computer and use it in GitHub Desktop.
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
constructor() public { | |
symbol = "EXAMPLE"; | |
name = "Example token"; | |
decimals = 18; | |
supply = 21000000 * 10**uint(decimals); | |
balances[owner] = supply; | |
emit Transfer(address(0), owner, supply); | |
} | |
constructor() public { | |
symbol = "EXAMPLE"; | |
name = "Example token"; | |
decimals = 18; | |
supply = 21000000 * 10**uint(decimals); | |
balances[owner] = supply; | |
emit Transfer(address(0), owner, supply); | |
} | |
function totalSupply() constant public returns (uint256) { | |
return supply; | |
} | |
function allowance(address _owner, address _spender) public constant | |
returns (uint256 remaining) { | |
return allowances[_owner][_spender]; | |
} | |
function balanceOf(address _owner) constant returns (uint256 balance) { | |
return balances[_owner]; | |
} | |
function transfer(address _to, uint256 _value) public returns (bool success) { | |
require(_value <= balances[msg.sender]); | |
//require(_to != address(0)); | |
// SafeMath.sub will throw if there is not enough balance. | |
balances[msg.sender] = balances[msg.sender].sub(_value); | |
balances[_to] = balances[_to].add(_value); | |
emit Transfer(msg.sender, _to, _value); | |
return true; | |
} | |
function approve(address _spender, uint256 _value) returns (bool success) { | |
allowances[msg.sender][_spender] = _value; | |
emit Approval(msg.sender, _spender, _value); | |
return true; | |
} | |
function transferFrom(address _from, address _to, uint256 _value) | |
returns (bool success) { | |
require(_to != address(0)); | |
require(_value <= balances[_from]); | |
require(_value <= allowances[_from][msg.sender]); | |
balances[_from] = balances[_from].sub(_value); | |
balances[_to] = balances[_to].add(_value); | |
allowances[_from][msg.sender] = allowances[_from][msg.sender].sub(_value); | |
emit Transfer(_from, _to, _value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment