Re:Learn Ethereum smart contract programming
by justinfrankel on Monday July 24, 2017 @07:56AM
(#14837686)
the lottery code is so broken it isn't even funny. actually it is hilarious! the first bet will almost always win, especially if it's a very small bet!
Re:Learn Ethereum smart contract programming
by jsnathan on Monday July 24, 2017 @05:55AM
(#14837105)
Yes, but the author does point to [1] for a better way of generating randomness for such a contract using commitments.
[1]: https://ethereum.stackexchange.com/questions/191/how-can-i-s...
Could you explain more how would it be possible?
Re:Learn Ethereum smart contract programming
by jsnathan on Monday July 24, 2017 @06:02AM
(#14837135)
In the example code used, the random number which determines the winner is derived from the previous block hash. Since the lottery-owner determines when the function is run, they could call the function when the previous block hash favors their own bet, or else modify their bet before calling the function.
Yep that is why there is a notice and link about random number generation in the tutorial.
try this lottery code instead https://github.com/renasboy/ETHLottery
[1]: https://ethereumdev.io/managing-multiple-users-a-simple-lott...