Skip to content

Instantly share code, notes, and snippets.

@wadealexc
Created June 24, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wadealexc/7a18de852693b3f890560ab6a211a2b8 to your computer and use it in GitHub Desktop.
Save wadealexc/7a18de852693b3f890560ab6a211a2b8 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.23;
contract FunctionTypes {
constructor() public payable { require(msg.value != 0); }
function withdraw() private {
require(msg.value == 0, 'dont send funds!');
address(msg.sender).transfer(address(this).balance);
}
function frwd() internal
{ withdraw(); }
struct Func { function () internal f; }
function breakIt() public payable {
require(msg.value != 0, 'send funds!');
Func memory func;
func.f = frwd;
assembly { mstore(func, add(mload(func), callvalue)) }
func.f();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment