The following solidity code segment aim to select a winner at
random from the a set of players (assume num_player is the
number of players). Explain what is the vulnerability of this
method.
contract Game {
uint winner_ID;
uint num_player;
function guessing() external{
winner_ID = uint256(block.blockhash(block.number -
1)) % num_player;
}
}
The following solidity code segment aim to select a winner at random from the a set of players (assume num_player is the
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am