// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; contract LuckyDraw { uint256 public jackpot; bool public solved; address public solver; bytes32 private flag; constructor(bytes32 _flag) payable { jackpot = msg.value; flag = _flag; } function play(uint256 _guess) external payable { require(msg.value == 0.01 ether); jackpot += msg.value; uint256 secret = uint256(keccak256(abi.encodePacked( block.timestamp, block.prevrandao, address(this) ))); if (_guess == secret) { if (!solved) { solved = true; solver = tx.origin; } uint256 prize = jackpot; jackpot = 0; (bool ok,) = msg.sender.call{value: prize}(""); require(ok); } } function isSolved() external view returns (bool) { return solved; } function getFlag() external view returns (string memory) { require(solved, "Solve the challenge first to get the flag!"); return string(abi.encodePacked(flag)); } receive() external payable { jackpot += msg.value; } }