Skip to content

Instantly share code, notes, and snippets.

@0mkara
Created January 7, 2019 13:33
Show Gist options
  • Save 0mkara/f03dceae24de0cc39a7f3c299e18577d to your computer and use it in GitHub Desktop.
Save 0mkara/f03dceae24de0cc39a7f3c299e18577d to your computer and use it in GitHub Desktop.
Greeter
pragma solidity ^0.5.0;
contract Mortal {
/* Define variable owner of the type address */
address payable owner;
/* This function is executed at initialization and sets the owner of the contract */
function mortal() public { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() public { if (msg.sender == owner) selfdestruct(owner); }
}
contract Greeter 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment