Last active
October 4, 2022 14:04
-
-
Save AayushmanThapaMagar/b2f475d5067a7cdd1204773e3ccaf598 to your computer and use it in GitHub Desktop.
Example contract for TOD mitigation.
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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| contract numGuess { | |
| address public winner; | |
| mapping (address => bytes32) public playerHashes; | |
| function storeHash(bytes32 _hash) external { | |
| playerHashes[msg.sender] = _hash; | |
| } | |
| function guess(uint _answer, uint _salt) external { | |
| require (keccak256(abi.encodePacked(_answer, _salt, msg.sender)) == playerHashes[msg.sender]); | |
| require (_answer == 9841984198); | |
| winner = msg.sender; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment