-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.10; | ||
|
||
/* | ||
Block timestamp manipulation | ||
Basic idea of the exploit | ||
- Miners can manipulate block.timestamp with some constraints | ||
Constraints | ||
- it must be after the previous block timestamp | ||
- it cannot be too far in the future | ||
*/ | ||
|
||
contract Roulette { | ||
constructor() public payable {} | ||
|
||
function spin() external payable { | ||
require(msg.value >= 1 ether); // must send 1 ether to play | ||
|
||
if (block.timestamp % 7 == 0) { | ||
(bool sent, ) = msg.sender.call{value: address(this).balance}(""); | ||
require(sent, "Failed to send Ether"); | ||
} | ||
} | ||
} |