Skip to content

Instantly share code, notes, and snippets.

@jdetychey
Created November 16, 2017 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdetychey/43d68a3b836735728697cd48c9d8edf8 to your computer and use it in GitHub Desktop.
Save jdetychey/43d68a3b836735728697cd48c9d8edf8 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.11;
contract Payer {
function pay(address _a) payable {
secureSend(_a, msg.value);
}
function secureSend(address a, uint v) internal {
if (v < address(this).balance) throw;
assembly {
let x := mload(0x40) //Find empty storage location using "free memory pointer"
mstore8(x,0x7f) //PUSH32
mstore(add(x,1), a)
mstore8(add(x,0x21), 0xff) // SELFDESTRUCT
let payer := create(v, x, 0x22)
jumpi(err, eq(payer, 0))
jump(end)
err:
invalid()
end:
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment