Created
July 3, 2018 19:48
-
-
Save pertsev/7b839682954aa2a1d814554c13783e99 to your computer and use it in GitHub Desktop.
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
contract Sender { | |
function contractFallbackHack(address _to, uint value, bytes _data) | |
private | |
returns(bool) | |
{ | |
return _to.call(abi.encodeWithSignature("onTokenTransfer(address,uint256,bytes)", msg.sender, value, _data)); | |
} | |
function transferAndCallHack(address _to, uint value, bytes _data) | |
external returns (bool) | |
{ | |
if(isContract(_to)){ | |
return contractFallbackHack(_to, value, _data); | |
} | |
return true; | |
} | |
function isContract(address _addr) | |
private | |
view | |
returns (bool) | |
{ | |
uint length; | |
assembly { length := extcodesize(_addr) } | |
return length > 0; | |
} | |
} | |
contract Recipient { | |
address public who; | |
uint public value; | |
bytes public data; | |
function () payable { | |
revert(); | |
} | |
function onTokenTransfer(address _who, uint256 _value, bytes _data) returns(bool) { | |
who = _who; | |
value = _value; | |
data = _data; | |
return true; | |
} | |
} | |
contract Recipient2 { | |
address public who; | |
function () payable { | |
revert(); | |
} | |
} | |
contract Recipient3 { | |
address public who; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment