-
Notifications
You must be signed in to change notification settings - Fork 48
/
Hello.sol
30 lines (23 loc) · 976 Bytes
/
Hello.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
pragma solidity ^0.4.24;
/*
Validity Labs AG, 2018, MIT license
a simple introduction smart contract
with an example of how to set and get values in Solidity
*/
contract Hello {
// making this property `public` automatically creates a getter, so `getGreeting` is not really needed
string public greeting;
// for event logging that allows to easily list past greetings in javascript
event GotGreeting(string);
// setter function
function setGreeting(string newGreeting) public {
greeting = newGreeting;
emit GotGreeting(newGreeting);
}
// getter function, should be marked as `view` so that the value can be querried from javascript
// `view` functions cannot change any contract properties that are written to storage
// e.g. this function could not change the value of the property `greeting`.
function getGreeting() public view returns (string g) {
g = greeting;
}
}