Last active
December 8, 2021 11:02
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=fdca67f3fb1325b4a85c4723dd9694cf
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract Caller { | |
uint256 flag = 0; | |
event InsideBeforeDelegate(); | |
event InsideAfterDelegate(); | |
event OutsideAfterAllWtf(); | |
function foo() external returns (uint256) { | |
flag++; | |
emit InsideBeforeDelegate(); | |
address target = address(new Logic()); | |
(bool res, ) = target.delegatecall(abi.encodeWithSelector(Logic.bar.selector)); | |
require(res, "FAIL_DELEGATE"); | |
flag++; | |
emit InsideAfterDelegate(); | |
this.lolz(); | |
return flag; | |
} | |
function lolz() external { | |
require(msg.sender == address(this), "a la shaggy"); | |
flag++; | |
emit OutsideAfterAllWtf(); | |
} | |
} | |
contract Logic { | |
uint256 flag; | |
event InsideBeforeDestruct(); | |
event InsideAfterDestruct(); | |
function bar() external { | |
flag++; | |
emit InsideBeforeDestruct(); | |
selfdestruct(payable(address(0))); | |
flag++; | |
emit InsideAfterDestruct(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment