Dapatkan nomor acak dalam soliditas
// Solidity pseudo-random function:
function random() private view returns (uint) {
// sha3 and now have been deprecated
return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, players)));
// convert hash to integer
// players is an array of entrants
}
// invoke random function in a pickWinner example function
function pickWinner() public {
uint index=random()%players.length;
}
Anxious Alligator