Created
February 7, 2022 06:53
-
-
Save brockelmore/e261804330a8cf95aca05b003d61ead5 to your computer and use it in GitHub Desktop.
Accessing private function outside of the contract
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
// SPDX-License-Identifier: UNLICENSE | |
pragma solidity >=0.8.0 <0.9.0; | |
contract Private { | |
function t_() private returns (uint256) { | |
return 1; | |
} | |
function rt() public returns (bytes32 fp) { | |
function () returns (uint256) t = t_; | |
assembly { | |
fp := t | |
} | |
} | |
} | |
contract P is Private { | |
function p(bytes32 fp) public returns (uint256) { | |
function () returns (uint256) t; | |
assembly { | |
t := fp | |
} | |
return t(); | |
} | |
// the below, if uncommented makes this contract not compile | |
// function f() public returns (uint256) { | |
// return t_(); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment