Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/main/solidity/greeter/Greeter.sol
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
pragma solidity ^0.4.25;

// Modified Greeter contract. Based on example at https://www.ethereum.org/greeter.
pragma solidity >=0.4.22 <0.6.0;

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

/* this function is executed at initialization and sets the owner of the contract */
constructor () public { owner = msg.sender; }
/* 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(owner); }
function kill() public { if (msg.sender == owner) selfdestruct(msg.sender); }
}

contract Greeter is Mortal {
/* define variable greeting of the type string */
/* Define variable greeting of the type string */
string greeting;

/* this runs when the contract is executed */
constructor (string _greeting) public {
/* This runs when the contract is executed */
constructor(string memory _greeting) public {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the reason for adding the memory declaration to strings? As function parameters is this not already implicit? I'd like to keep the code as simple as possible for users unfamiliar to Solidity, so I'd rather keep the memory declaration out if we can.

greeting = _greeting;
}

function newGreeting(string _greeting) public {
function newGreeting(string memory _greeting) public {
emit Modified(greeting, _greeting, greeting, _greeting);
greeting = _greeting;
}

/* main function */
function greet() public constant returns (string) {
/* Main function */
function greet() public view returns (string memory) {
return greeting;
}

/* we include indexed events to demonstrate the difference that can be
captured versus non-indexed */
captured versus non-indexed */
event Modified(
string indexed oldGreetingIdx, string indexed newGreetingIdx,
string oldGreeting, string newGreeting);
}
string indexed oldGreetingIdx, string indexed newGreetingIdx,
string oldGreeting, string newGreeting);
}