Building a decentralized lottery on Ethereum
Distributed technologies are some of the most suitable platforms for running decentralized organizations. A Decentralized Autonomous Organization (DAO) is an organization that is run through the rules encoded in a smart contract. You can use Ethereum to create your own DAOs with the set of rules hardcoded inside the contract.
In this recipe, you will learn how to create a decentralized organization that runs a lottery system on Ethereum blockchain.
Getting ready
You need to have a working installation of Ethereum (geth
, Parity
, ganache
, and so on) or the Remix IDE to test this recipe.
The contracts given are for illustration purposes only and cannot be used in real-world systems.
How to do it…
Let's consider a lottery system that selects the winning numbers based on a future block hash. While buying a ticket, the user is asked to guess a random set of numbers and is validated against some future block. The prize is given based on how accurate the prediction...