next block hash, that clearly cannot be known when the decisions were made), then generate the random(ish) number. After the careful addition of an extra challenge (e.g. In step 1, players lock in their decisions. If there is any incentive to guess the "random" numbers (card game, lottery, etc.) then a popular pattern is commit and reveal. Suffice it say this is not a safe way to do it. The method of attack would be another question. The block hash looks hard to guess because it's in the future. The nonce scrambles it up if two transactions go through in the same block. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs. The wrapping is merely doing explicit type conversions from a hash to an address. RANDOM.ORG offers true random numbers to anyone on the Internet. You can "spice it up" a little: address randomish = address(uint160(uint(keccak256(abi.encodePacked(nonce, blockhash(block.number))))))
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |