Created
December 6, 2018 17:38
-
-
Save nachinius/721694364924b592098fdd294e985ba3 to your computer and use it in GitHub Desktop.
A contract that can receive money in its address, can be killed, and is a greeter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity >=0.4.22 <0.6.0; | |
| contract Mortal { | |
| /* Define variable owner of the type address */ | |
| address owner; | |
| /* This constructor is executed at initialization and sets the owner of the contract */ | |
| constructor() public { owner = msg.sender; } | |
| /* Function to recover the funds on the contract */ | |
| function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); } | |
| } | |
| contract PayableGreeter is Mortal { | |
| /* Define variable greeting of the type string */ | |
| string greeting; | |
| /* This runs when the contract is executed */ | |
| constructor(string memory _greeting) public { | |
| greeting = _greeting; | |
| } | |
| /* Main function */ | |
| function greet() public view returns (string memory) { | |
| return greeting; | |
| } | |
| function() payable external {} | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created at https://rinkeby.etherscan.io/tx/0xa82e583c410190f2e5512a8ded8a0fb1f06794cf7e922dc534112e7d77332808