Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
Add init fn
Browse files Browse the repository at this point in the history
  • Loading branch information
izqui committed Jan 31, 2017
1 parent 7d4a620 commit 7db34f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions contracts/token/ERC20Lib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ library ERC20Lib {
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);

function init(TokenStorage storage self, uint _initial_supply) {
self.totalSupply = _initial_supply;
self.balances[msg.sender] = _initial_supply;
}

function transfer(TokenStorage storage self, address _to, uint _value) internal returns (bool success) {
self.balances[msg.sender] = self.balances[msg.sender].minus(_value);
self.balances[_to] = self.balances[_to].plus(_value);
Expand Down
3 changes: 1 addition & 2 deletions contracts/token/StandardToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import './ERC20Lib.sol';
uint public INITIAL_SUPPLY = 10000;

function StandardToken() {
token.totalSupply = INITIAL_SUPPLY;
token.balances[msg.sender] = INITIAL_SUPPLY;
token.init(INITIAL_SUPPLY);
}

function totalSupply() constant returns (uint) {
Expand Down

0 comments on commit 7db34f7

Please sign in to comment.