Skip to content

Instantly share code, notes, and snippets.

@AayushmanThapaMagar
Last active October 4, 2022 14:04
Show Gist options
  • Select an option

  • Save AayushmanThapaMagar/b2f475d5067a7cdd1204773e3ccaf598 to your computer and use it in GitHub Desktop.

Select an option

Save AayushmanThapaMagar/b2f475d5067a7cdd1204773e3ccaf598 to your computer and use it in GitHub Desktop.
Example contract for TOD mitigation.
// 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