Intro to Smart Contract Security Audits | Randomness

  • Generating Randomness using block variables
  • Generating Randomness through the use of an oracle
  • abi.encodePacked encodes the parameters. Solidity provides two encoding methods, encode and encodePacked. The former fills each parameter with 32 bytes, and the latter doesn’t fill up, but directly connects the parameters to be encoded.
  • The keccak256 hash algorithm can compress any length of input into a 64-bit hexadecimal number, with the probability of hash collision being close to 0.
  1. Alice deploys the GuessTheRandomNumber contract with one Ether
  2. Eve deploys the Attack contract to call the attack() function and passes in the address of the GuessTheRandomNumber contract
  3. Eve wins one Ether

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store