Created
October 6, 2022 16:04
-
-
Save BedrosovaYulia/7abc763c3ca24b7affd8f4e22e62baef 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
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.17; | |
contract GuessRandomNumber { | |
function guess(uint256 _number) | |
public payable{ | |
require( | |
msg.value >= 10 gwei, | |
"please send more money!" | |
); | |
uint256 randomNumber = ( | |
block.timestamp * | |
block.number * | |
block.difficulty) % 10; | |
if (_number == randomNumber){ | |
(bool os, ) = payable(msg.sender).call{ | |
value: address(this).balance | |
}(""); | |
require(os); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment