Skip to content

Instantly share code, notes, and snippets.

@xd4rker
Created April 14, 2018 15:58
Show Gist options
  • Save xd4rker/4cb7f2da09e0034065cb60d310bb74fe to your computer and use it in GitHub Desktop.
Save xd4rker/4cb7f2da09e0034065cb60d310bb74fe to your computer and use it in GitHub Desktop.
Guess the secret number - capturetheether.com
pragma solidity ^0.4.21;
contract GuessTheSecretNumberChallenge {
bytes32 answerHash = 0xdb81b4d58595fbbbb592d3661a34cdca14d7ab379441400cbfa1b78bc447c365;
function GuessTheSecretNumberChallenge() 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 (keccak256(n) == answerHash) {
msg.sender.transfer(2 ether);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment