Blockchains are designed to be deterministic, with all interactions viewable and traceable. How then can we access randomness to use in our contracts? One might think we can query some value that isn't random but can be hard to predict, like the block number, and process it with some algorithm to get our desired random number. This may seem clever, but an attacker can make his own smart contract that uses the same methods to predict your random value in advance. This is the vulnerability found in Open Zeppelin's Ethernaut 3 challenge, where a coin flip game determines the result based on the block number. This contract can be exploited by a second contract calculates whether the coin will land heads or tails using the same exact math, and then guesses correctly every time. This simple contract illustrates the challenges of consuming random data on-chain. Various solutions exist, such as Chainlink's Verifiable Randomness call that can inject random data into your contract from an oracle.
Subscribe to:
Post Comments (Atom)
190: Sablier
The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...
-
The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...
-
The ZKasino project recently exit scammed over 33 million dollars worth of Ethereum. he recent debacle surrounding ZKasino offers valuable...
-
In addition to its native SDK, Hedera also supports smart contracts in a platform compatible with the Ethereum Virtual Machine. This allows ...
No comments:
Post a Comment