An Ethereum Project (1) – The idea

A decentralised lottery

A lottery draw is an event where three things need to happen:

    1. Players need to buy tickets and trust that these are entered in the draw. A pot is made with the ticket money in a transparent way – 10% goes in admin fees and the rest in prizes.

    2. A draw needs to take place where numbers are selected at random. Everyone needs to trust that the draw is truly random.

    3. The winner(s) need to be paid a portion of the pot. Everyone needs to trust that winners will be paid fairly. If no winner emerges the pot gets rolled over into the next draw


Now, up until now the trust factors have been held by a third party, e.g. the National Lottery. Everyone trusts them to sell the tickets, draw numbers transparently and pay the winners. Most of the flim-flam around those events -tv draws with music and celebrities, big photo ops with cardboard cheques and champagne etc- are just flashy props to hide a pretty straightforward process.

But with Ethereum you could replace all the third party trust. Here’s how:

1. Buy tickets. A draw is a contract on the Ethereum blockchain. You can pay for a ticket with Ether into the contract’s wallet from your wallet. Your wallet address is now your ticket. It is associated to the numbers you chose. Both of those values are stored in the contract. If you win, you get paid into that wallet.
2. Do the draw The pot is the value of ether in the contract. At an appointed draw time the draw is done by the contract picking some numbers at random. It then runs over the database of entries and works out whether or not anyone won.
3. Pay the winner(s). If the smart contract finds a winner or winners, it divides the pot among them and pays out the ether to the winning addresses.
4. Rollovers – if there is no winner it can transfer the pot to the smart contract of the next draw.

The beauty of this?

1. It is anonymous (or pseudonymous). You play with your ether wallet address. You get paid to your ether wallet address. No need to register. You can buy as many tickets as you want. Every time you pay, your address is entered again.
2. It is totally transparent and auditable. For every draw, you publish the address that receives the money, so anyone can go and figure out if the pot is correct. You can also see who paid into that pot (i.e. who was entered into the draw) and even what numbers they chose.
The smart contract is also public, i.e. the algorithm that picks the numbers, and the address(es) of the winner(s) are known. And it can be demonstrated that the winners got paid (because the draw contract publicly pays out). All of which means that…
3. It is trust-less. No third party is required to ensure things are above board. Anyone can check.

Easy, right? So I decided to have a crack at it. Read on…