Skip to content

Instantly share code, notes, and snippets.

@Enigmatic331
Created September 23, 2018 13:32
Show Gist options
  • Save Enigmatic331/49ec2c9f9520acb6289db0cd65c29b48 to your computer and use it in GitHub Desktop.
Save Enigmatic331/49ec2c9f9520acb6289db0cd65c29b48 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.21;
contract GuessTheNumberChallenge {
uint8 answer = 42;
function GuessTheNumberChallenge() public payable {
require(msg.value == 1 ether);
}
function isComplete() public view returns (bool) {
return address(this).balance == 0;
}
function guess(uint8 n) public payable {
require(msg.value == 1 ether);
if (n == answer) {
msg.sender.transfer(2 ether);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment