Skip to content

Instantly share code, notes, and snippets.

@shayanb
Last active October 12, 2017 00:06
Show Gist options
  • Save shayanb/d417cfd229c0980d0fbc2a63dde001a5 to your computer and use it in GitHub Desktop.
Save shayanb/d417cfd229c0980d0fbc2a63dde001a5 to your computer and use it in GitHub Desktop.
Hello World Solidity Sample - EthWaterloo
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