Spaces:
Sleeping
Sleeping
Arshit-Verma
feat: Complete SolidityGuard v2.0 with exploit proofs, auto-fix suggestions, multi-agent verification, and advanced reporting
5de1250 Download data/samples/task3/weak_randomness.sol from tanaymitra01/solidityguard-openenv: direct link, hf CLI and curl.
- Browser
- Download file 827 Bytes
-
https://huggingface.co/spaces/tanaymitra01/solidityguard-openenv/resolve/main/data/samples/task3/weak_randomness.sol
- Command line
-
hf download hf://spaces/tanaymitra01/solidityguard-openenv/data/samples/task3/weak_randomness.sol
-
curl -L -o weak_randomness.sol https://huggingface.co/spaces/tanaymitra01/solidityguard-openenv/resolve/main/data/samples/task3/weak_randomness.sol
827 Bytes
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.20; | |
| contract RandomnessVulnerability { | |
| mapping(address => bool) public hasWon; | |
| uint256 public prize = 1 ether; | |
| function playLottery() external payable { | |
| require(msg.value >= 0.1 ether, "Insufficient payment"); | |
| // Vulnerable randomness using block properties | |
| uint256 randomNumber = uint256(keccak256(abi.encodePacked( | |
| block.timestamp, | |
| block.difficulty, | |
| msg.sender | |
| ))) % 100; | |
| if (randomNumber < 10) { | |
| hasWon[msg.sender] = true; | |
| payable(msg.sender).transfer(prize); | |
| } | |
| } | |
| function getBlockHash() external view returns (bytes32) { | |
| // Predictable block hash usage | |
| return blockhash(block.number - 1); | |
| } | |
| } |