Last active
October 12, 2017 00:06
-
-
Save shayanb/d417cfd229c0980d0fbc2a63dde001a5 to your computer and use it in GitHub Desktop.
Hello World Solidity Sample - EthWaterloo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.12; | |
contract helloworld { | |
address private Owner; | |
string public sayHello; | |
function helloworld() { | |
Owner = msg.sender; | |
sayHello = "Hello"; | |
} | |
modifier isOwner() { if (msg.sender != Owner) revert(); _ ;} | |
event echoInputEvent(address indexed from, bytes32 str); | |
//Rejector function (fallback). rejects all payments . also with payable() | |
function() public { revert(); } | |
function echoFree(bytes32 inputStr) constant public returns(bytes32){ | |
//constant functions are free, no gas required | |
// but they can't change any state or trigger events | |
return (inputStr); | |
} | |
function echo(bytes32 inputStr) public returns(bytes32){ | |
//Events require gas | |
//bytes to str : http://string-functions.com/hex-string.aspx | |
echoInputEvent(msg.sender, inputStr); | |
return (inputStr); | |
} | |
function hiBack() public isOwner() { | |
//isOwner modifier makes sure only owner can call this function | |
sayHello = "Hello to you too"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment