Skip to content

Instantly share code, notes, and snippets.

@Georgi87
Created October 27, 2016 17:44
Show Gist options
  • Save Georgi87/fde861435d99fb21a54c3f29204bd9b7 to your computer and use it in GitHub Desktop.
Save Georgi87/fde861435d99fb21a54c3f29204bd9b7 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.0;
/// @title Standard token contract - Standard token interface implementation.
contract StandardToken {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
function transfer(address _to, uint256 _value)
public
{
if (balances[msg.sender] < _value) {
throw;
}
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value)
public
{
if (balances[_from] < _value || allowed[_from][msg.sender] < _value) {
throw;
}
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
}
function approve(address _spender, uint256 _value)
public
{
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
function allowance(address _owner, address _spender)
constant
public
returns (uint256 remaining)
{
return allowed[_owner][_spender];
}
function balanceOf(address _owner)
constant
public
returns (uint256 balance)
{
return balances[_owner];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment