Sitemap
Better Programming

Advice for programmers.

Build a Verifiably Random Lottery Smart Contract on Ethereum

How to create an Ethereum lottery

4 min readJun 1, 2020

--

Press enter or click to view image in full size
Photo by dylan nolte on Unsplash

Editor’s note: This article is provided for entertainment and educational purposes only and does not constitute or contain financial advice. Any actions you take from the content of this article are solely your own.

True randomness has been near impossible on Ethereum. This is because transactions need to be verified by multiple nodes on the network to be confirmed. If a smart contract function were truly random, each node that verified a transaction using that function would come to a different result, meaning the transaction would never be confirmed.

A recent announcement by one of the biggest players in the Ethereum ecosystem has caused excitement around this very problem. Using a system called a Verifiable Random Function (VRF), Ethereum smart contracts can now generate random numbers.

This means concepts that seemed a perfect fit with smart contracts but couldn’t be brought to life because they required random numbers now can be.

One such concept is that of a lottery.

Building a Lottery Smart Contract

Our lottery is going to have three phases. The first is open, where new numbers can be submitted by anyone…

--

--

Responses (1)