github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/examples/create_stateful_contract/stateful.sol (about) 1 pragma solidity >=0.4.22 <0.7.0; 2 3 contract StatefulContract { 4 // the contract's owner, set in the constructor 5 address owner; 6 7 // the message we're storing 8 string message; 9 10 constructor(string memory message_) public { 11 // set the owner of the contract for `kill()` 12 owner = msg.sender; 13 message = message_; 14 } 15 16 function setMessage(string memory message_) public { 17 // only allow the owner to update the message 18 if (msg.sender != owner) return; 19 message = message_; 20 } 21 22 // return a string 23 function getMessage() public view returns (string memory) { 24 return message; 25 } 26 27 // recover the funds of the contract 28 function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); } 29 }