Created
August 18, 2018 21:12
-
-
Save jim380/4712a75506881ed151c206047e615d91 to your computer and use it in GitHub Desktop.
transferProxy() snippet
This file contains hidden or 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
function transferProxy(address _from, address _to, uint256 _value, uint256 _fee, | |
uint8 _v, bytes32 _r, bytes32 _s) public returns (bool){ | |
if(balances[_from] < _fee + _value || _fee > _fee + _value) revert(); | |
uint256 nonce = nonces[_from]; | |
bytes32 h = keccak256(_from,_to,_value,_fee,nonce); | |
if(_from != ecrecover(h,_v,_r,_s)) revert(); | |
if(balances[_to] + _value < balances[_to] | |
|| balances[msg.sender] + _fee < balances[msg.sender]) revert(); | |
balances[_to] += _value; | |
emit Transfer(_from, _to, _value); | |
balances[msg.sender] += _fee; | |
emit Transfer(_from, msg.sender, _fee); | |
balances[_from] -= _value + _fee; | |
nonces[_from] = nonce + 1; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment