Horje
get random number in solidity Code Example
get random number in solidity
// 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;
}




Javascript

Related
update node-modules Code Example update node-modules Code Example
how to run method in method vue js on load Code Example how to run method in method vue js on load Code Example
js string to date Code Example js string to date Code Example
navigating programatically react Code Example navigating programatically react Code Example
javascript int to time format Code Example javascript int to time format Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8