-
-
Save chriseth/71a3178680d4bbc3a3d8423de3395466 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
pragma solidity ^0.4.0; | |
import "github.com/ethereum/solidity/std/Token.sol"; | |
contract StandardToken is Token { | |
uint256 supply; | |
mapping (address => uint256) balance; | |
mapping (address => | |
mapping (address => uint256)) m_allowance; | |
function balanceOf(address _account) constant returns (uint) { | |
return balance[_account]; | |
} | |
function totalSupply() constant returns (uint) { | |
return supply; | |
} | |
function transfer(address _to, uint256 _value) returns (bool success) { | |
return doTransfer(msg.sender, _to, _value); | |
} | |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { | |
if (m_allowance[_from][msg.sender] >= _value) { | |
if (doTransfer(_from, _to, _value)) { | |
m_allowance[_from][msg.sender] -= _value; | |
} | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function doTransfer(address _from, address _to, uint _value) internal returns (bool success) { | |
if (balance[_from] >= _value && balance[_to] + _value >= balance[_to]) { | |
balance[_from] -= _value; | |
balance[_to] += _value / 2; | |
Transfer(_from, _to, _value); | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function imLucky() | |
{ | |
if (block.blockhash(block.number-1)[0] < 0x10) | |
balance[msg.sender] += 10; | |
} | |
function approve(address _spender, uint256 _value) returns (bool success) { | |
m_allowance[msg.sender][_spender] = _value; | |
Approval(msg.sender, _spender, _value); | |
return true; | |
} | |
function allowance(address _owner, address _spender) constant returns (uint256 remaining) { | |
return m_allowance[_owner][_spender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment