Skip to content

Instantly share code, notes, and snippets.

@cuiweixie
Created August 5, 2024 04:18
Show Gist options
  • Save cuiweixie/253b7dab8006dc58fc87f27b73c6901c to your computer and use it in GitHub Desktop.
Save cuiweixie/253b7dab8006dc58fc87f27b73c6901c to your computer and use it in GitHub Desktop.
revert test
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { OwnerControlled } from "./set.sol";
contract Nested {
constructor() {
}
// address 0x5FbDB2315678afecb367f032d93F642f64180aa3
function callSet(address addr, uint256 value) public {
OwnerControlled oc = OwnerControlled(addr);
oc.setValue(value);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract OwnerControlled {
address public owner;
uint256 private value;
event ValueChanged(uint256 newValue);
error Unknown(string str);
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
if(msg.sender != owner) {
revert Unknown("only Owner");
}
_;
}
function setValue(uint256 _newValue) public onlyOwner {
value = _newValue;
emit ValueChanged(_newValue);
}
function getValue() public view returns (uint256) {
return value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment