© Wei-Meng Lee 2019
W.-M. LeeBeginning Ethereum Smart Contracts Programminghttps://doi.org/10.1007/978-1-4842-5086-0_10

10. Project – Online Lottery

Wei-Meng Lee1 
(1)
Ang Mo Kio, Singapore
 

Now that you have seen how Smart Contract works and how to interact with them through the use of the web3.js APIs, it is now a good time to explore an application from end to end – from the Smart Contract to the front end, and perhaps give you some ideas for building your own decentralized applications.

How the Lottery Game Works

For this chapter, we will build a lottery game using a Smart Contract. For this contract, we will allow players to place a bet on a number. Figure 10-1 shows how the game works.
Figure 10-1

How the online lottery game works

In the figure, there ...

Get Beginning Ethereum Smart Contracts Programming: With Examples in Python, Solidity, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.