Skip to content

Instantly share code, notes, and snippets.

@mattlockyer
Created June 6, 2018 17:53
Show Gist options
  • Save mattlockyer/d7068dcfa2e90eea9fa36b0900d0ff30 to your computer and use it in GitHub Desktop.
Save mattlockyer/d7068dcfa2e90eea9fa36b0900d0ff30 to your computer and use it in GitHub Desktop.
HelloMarket smart contract for Solidity workshops
//jshint ignore: start
pragma solidity ^0.4.21;
contract Owner {
address public owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address _to) public onlyOwner {
owner = _to;
}
}
contract HelloMarket is Owner {
uint256 public price;
string public message;
constructor() public {
owner = msg.sender;
}
event Talk(string _message, address _from);
function talk(string _message) public onlyOwner {
message = _message;
emit Talk(_message, msg.sender);
}
function buyRights() payable public returns (bool) {
if (msg.value > price) {
owner = msg.sender;
price = msg.value;
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment