Skip to content

Instantly share code, notes, and snippets.

@brockelmore
Created February 7, 2022 06:53
Show Gist options
  • Save brockelmore/e261804330a8cf95aca05b003d61ead5 to your computer and use it in GitHub Desktop.
Save brockelmore/e261804330a8cf95aca05b003d61ead5 to your computer and use it in GitHub Desktop.
Accessing private function outside of the contract
// 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