-
Notifications
You must be signed in to change notification settings - Fork 8
/
Greeter.sol
38 lines (30 loc) · 1.03 KB
/
Greeter.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pragma solidity 0.6.5;
import "hardhat/console.sol";
contract Greeter {
string greeting;
address _admin;
constructor(address admin, string memory _greeting) public {
console.log("Deploying a Greeter with greeting:", _greeting);
greeting = _greeting;
_admin = admin;
}
function greet() public view returns (string memory) {
return greeting;
}
function setGreeting(string memory _greeting) public {
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
greeting = _greeting;
revert("testing error blocking");
}
function setGreetingThatWorks(string memory _greeting) public {
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
greeting = _greeting;
}
function getAdmin() external view returns (address admin) {
return _admin;
}
function setAdmin(address newAdmin) external {
require(msg.sender == _admin, "NOT_AUTHORIZED_ADMIN");
_admin = newAdmin;
}
}