Created
January 19, 2018 11:18
-
-
Save goastoman/bcb48344be8826217f7501d02472dc80 to your computer and use it in GitHub Desktop.
Simple ERC20 token for deploying
This file contains hidden or 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
pragma solidity ^0.4.11; | |
import "./ERC20Standard.sol"; | |
contract NewToken is ERC20Standard { | |
function NewToken() { | |
totalSupply = 1000000; | |
name = "All you need coin"; | |
decimals = 6; | |
symbol = "AYN"; | |
version = "1.0"; | |
balances[msg.sender] = totalSupply; | |
} | |
} |
This file contains hidden or 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
pragma solidity ^0.4.11; | |
contract ERC20Standard { | |
uint public totalSupply; | |
string public name; | |
uint8 public decimals; | |
string public symbol; | |
string public version; | |
mapping (address => uint256) balances; | |
mapping (address => mapping (address => uint)) allowed; | |
modifier onlyPayloadSize(uint size) { | |
assert(msg.data.length == size + 4); | |
_; | |
} | |
function balanceOf(address _owner) constant returns (uint balance) { | |
return balances[_owner]; | |
} | |
function transfer(address _recipient, uint _value) onlyPayloadSize(2*32) { | |
require(balances[msg.sender] >= _value && _value > 0); | |
balances[msg.sender] -= _value; | |
balances[_recipient] += _value; | |
Transfer(msg.sender, _recipient, _value); | |
} | |
function transferFrom(address _from, address _to, uint _value) { | |
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0); | |
balances[_to] += _value; | |
balances[_from] -= _value; | |
allowed[_from][msg.sender] -= _value; | |
Transfer(_from, _to, _value); | |
} | |
function approve(address _spender, uint _value) { | |
allowed[msg.sender][_spender] = _value; | |
Approval(msg.sender, _spender, _value); | |
} | |
function allowance(address _spender, address _owner) constant returns (uint balance) { | |
return allowed[_owner][_spender]; | |
} | |
event Transfer( | |
address indexed _from, | |
address indexed _to, | |
uint _value | |
); | |
event Approval( | |
address indexed _owner, | |
address indexed _spender, | |
uint _value | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment