• Skip to primary navigation
  • Skip to main content
Daniel McClure

Daniel McClure

Entrepreneurship, Marketing, Technology, Travel & Lifestyle

  • About
  • Credentials
  • The Blog of Daniel McClure
  • Social
  • Code
  • Contact
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter

Ethereum Greeter Updated from v4

Code snippet posted to GitHub Gist by Daniel McClure.

You are here: Home » Code Snippets » #Ethereum » Ethereum Greeter Updated from v4

Last Updated: December 13, 2018 Leave a Comment

The following is a code snippet originally posted by Daniel McClure on GitHub as a Gist.

greeter.sol

“`
pragma solidity ^0.5.0;

contract mortal {
/* Define variable owner of the type address */
address owner;

/* This function is executed at initialisation and sets the owner of the contract */
constructor() public { owner = msg.sender; }

/* Function to recover the funds of the contract */
function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); }
}

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;
}
}
“`

Original Gist


pragma solidity ^0.5.0;
contract mortal {
/* Define variable owner of the type address */
address owner;
/* This function is executed at initialisation and sets the owner of the contract */
constructor() public { owner = msg.sender; }
/* Function to recover the funds of the contract */
function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); }
}
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;
}
}

view raw

greeter.sol

hosted with ❤ by GitHub

Filed Under: GitHub Gist Tagged With: #Ethereum, #Solidity

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

You can encrypt your comment so that only Daniel McClure can read it.

Daniel McClure

Work With Me

Get in touch if you’re interested in working together on your next project.

Contact Me

Creative Commons Licence

Copyright © 2025 Daniel McClure

All opinions shared through this site are that of their respective author and are not necessarily representative of the views of past/present clients, affiliate partners or businesses.
Some links include affiliate tracking for which I may earn a commission. See the Full Disclaimer Page for more information.