Skip to content

Instantly share code, notes, and snippets.

@nepalbitcoin
Created February 14, 2019 19:44
Show Gist options
  • Select an option

  • Save nepalbitcoin/b282b74cffabc497bf351ac22693bed0 to your computer and use it in GitHub Desktop.

Select an option

Save nepalbitcoin/b282b74cffabc497bf351ac22693bed0 to your computer and use it in GitHub Desktop.
pragma solidity >0.4.99 <0.6.0;
// Requires Constantinople EVM
// Use Ganache testrpc https://github.com/trufflesuite/ganache
// Run ("0x+Lazarus Bytecode", salt) in Resurrection function
// input e.g., "0xC0DE4COFFEE....FEFE", 42
contract Lazarus {
address public jesus;
event Alive(address addr, address dapp);
constructor() public {
jesus = msg.sender;
emit Alive(msg.sender, address(this)); // Namaste
}
function finishHim() external {
selfdestruct(msg.sender); // Dead again
}
}
contract Jesus {
event Lazarious(address lazarus, uint256 salt);
// ....
function Resurrection(bytes memory soul, uint256 salt) public {
address addr;
assembly {
addr := create2(0, add(soul, 0x20), mload(soul), salt)
//if iszero(extcodesize(addr))
// revert(0, 0)
}
emit Lazarious(addr, salt);
}
}
// @ solc 0.5.4, optimized
// "0x608060405234801561001057600080fd5b5060008054600160a060020a031916339081179091556040805191825230602083015280517f8d4d5a63280cb5e1c02dfa0d226005120e8fcf1db57b80999115227d056c362a9281900390910190a160d58061006d6000396000f3fe6080604052348015600f57600080fd5b5060043610604e577c01000000000000000000000000000000000000000000000000000000006000350463da4077b981146053578063da5c921e14605b575b600080fd5b6059608a565b005b6061608d565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b33ff5b60005473ffffffffffffffffffffffffffffffffffffffff168156fea165627a7a723058204a92401096f2b5c5dca112e019759d97ca47c961903eb836b1a4f87e5f3abf4a0029",42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment