Skip to content

Instantly share code, notes, and snippets.

@nachinius
Created December 6, 2018 17:38
Show Gist options
  • Select an option

  • Save nachinius/721694364924b592098fdd294e985ba3 to your computer and use it in GitHub Desktop.

Select an option

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.
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 {}
}
@nachinius
Copy link
Author

Created at https://rinkeby.etherscan.io/tx/0xa82e583c410190f2e5512a8ded8a0fb1f06794cf7e922dc534112e7d77332808

  • [Contract 0xf60772002bcd1856b7fa86774a32bb1994522f0a Created]
  • Gas Limit: 353682 Gas Used By Transaction:353682 (100%) Gas Price:0.000000001 Ether (1 Gwei) Actual Tx Cost/Fee:0.000353682 Ether ($0.000000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment