Last active
January 19, 2017 14:55
-
-
Save simondlr/b08f32eeb8f9eec52ec4124d13c18242 to your computer and use it in GitHub Desktop.
Barclays Prague Comms. Communicate here.
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
Barclays Prague Comms: | |
-> Paste address and other things in the comments. |
pragma solidity ^0.4.8;
contract Owner {
address owner;
function Owner() {
owner = msg.sender;
}
modifier isOwner() {
if(msg.sender == owner) {
_;
}
}
}
contract ERC20Asset is Owner {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowed;
function ERC20Asset() {
//balances[msg.sender] = 10000;
}
function deposit() payable {
balances[msg.sender] += msg.value;
}
function withdraw() {
if(!msg.sender.send(balances[msg.sender])) {
throw;
}
balances[msg.sender] = 0;
}
/*function mint(address _for, uint256 _value) isOwner {
balances[_for] += _value;
}
function destroy(address _for, uint256 _value) isOwner {
if(balances[_for] >= _value) {
balances[_for] -= _value;
} else {
balances[_for] = 0;
}
}*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) returns (bool success) {
//msg.sender
//tx.origin [BAD]
if(balances[msg.sender] >= _value) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else {
throw;
}
}
//function internalTransfer()
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
//spender == msg.sender
if(allowed[_from][msg.sender] >= _value && balances[_from] >= _value) {
balances[_from] -= _value;
balances[_to] += _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
return false;
}
function allowance(address _owner, address _spender) constant returns (uint amount) {
return allowed[_owner][_spender];
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0x93A0b7780dad967746c10444E48fcabA2278f74B