mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make token constructible.
This commit is contained in:
parent
61a15bb92e
commit
c6207e2761
@ -3,20 +3,28 @@ pragma solidity ^0.4.0;
|
||||
import "./Token.sol";
|
||||
|
||||
contract StandardToken is Token {
|
||||
uint256 public totalSupply;
|
||||
mapping (address => uint256) public balanceOf;
|
||||
uint256 supply;
|
||||
mapping (address => uint256) balance;
|
||||
mapping (address =>
|
||||
mapping (address => uint256)) public allowance;
|
||||
mapping (address => uint256)) m_allowance;
|
||||
|
||||
function StandardToken(address _initialOwner, uint256 _supply) {
|
||||
totalSupply = _supply;
|
||||
balanceOf[_initialOwner] = _supply;
|
||||
supply = _supply;
|
||||
balance[_initialOwner] = _supply;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
|
||||
balanceOf[msg.sender] -= _value;
|
||||
balanceOf[_to] += _value;
|
||||
if (balance[msg.sender] >= _value && balance[_to] + _value >= balance[_to]) {
|
||||
balance[msg.sender] -= _value;
|
||||
balance[_to] += _value;
|
||||
Transfer(msg.sender, _to, _value);
|
||||
return true;
|
||||
} else {
|
||||
@ -25,9 +33,9 @@ contract StandardToken is Token {
|
||||
}
|
||||
|
||||
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
|
||||
if (allowance[_from][msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
|
||||
allowance[_from][msg.sender] -= _value;
|
||||
balanceOf[_to] += _value;
|
||||
if (m_allowance[_from][msg.sender] >= _value && balance[_to] + _value >= balance[_to]) {
|
||||
m_allowance[_from][msg.sender] -= _value;
|
||||
balance[_to] += _value;
|
||||
Transfer(_from, _to, _value);
|
||||
return true;
|
||||
} else {
|
||||
@ -36,8 +44,12 @@ contract StandardToken is Token {
|
||||
}
|
||||
|
||||
function approve(address _spender, uint256 _value) returns (bool success) {
|
||||
allowance[msg.sender][_spender] = _value;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user