© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
W.-M. LeeBeginning Ethereum Smart Contracts Programminghttps://doi.org/10.1007/978-1-4842-9271-6_10

10. Project: Online Lottery

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

Now that you have seen how smart contracts work and how to interact with them using the web3.js APIs, it’s 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, you will build a lottery game using a smart contract. In this contract, you will allow players to place a bet on a number. Figure 10-1 shows how the game works.

A schematic ...

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.