forked from hashgraph/hedera-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stateful.sol
29 lines (23 loc) · 786 Bytes
/
stateful.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
pragma solidity >=0.4.22 <0.6.0;
contract StatefulContract {
// the contract's owner, set in the constructor
address owner;
// the message we're storing
string message;
constructor(string memory message_) public {
// set the owner of the contract for `kill()`
owner = msg.sender;
message = message_;
}
function set_message(string memory message_) public {
// only allow the owner to update the message
if (msg.sender != owner) return;
message = message_;
}
// return a string
function get_message() public view returns (string memory) {
return message;
}
// recover the funds of the contract
function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); }
}