Created
March 25, 2019 05:17
-
-
Save muellerberndt/e0a91db1645ab5cb30fee11d7bd54e0f to your computer and use it in GitHub Desktop.
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
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| /* | |
| * @source: https://capturetheether.com/challenges/lotteries/guess-the-random-number/ | |
| * @author: Steve Marx | |
| */ | |
| pragma solidity ^0.4.21; | |
| contract GuessTheRandomNumberChallenge { | |
| uint8 answer; | |
| function GuessTheRandomNumberChallenge() public payable { | |
| require(msg.value == 1 ether); | |
| answer = uint8(keccak256(block.blockhash(block.number - 1), now)); | |
| } | |
| 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