Skip to content

Instantly share code, notes, and snippets.

@xpdlf1004
Created May 25, 2018 16:00
Show Gist options
  • Save xpdlf1004/4b324c61a83f41be1f265671f068809b to your computer and use it in GitHub Desktop.
Save xpdlf1004/4b324c61a83f41be1f265671f068809b to your computer and use it in GitHub Desktop.
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment