Intro to Ethereum: Deploy a lottery app on blockchain. (part 1)

These days with increased concerns for security and autonomy, the need for decentralization of software has increased. Decentralized apps or DApps are apps whose server-client models are decentralized.

A decentralized app must meet the following criteria:

  • They should be open source and autonomous. This means that any changes can only be executed by consensus and there is no single body which holds majority tokens in the network.
  • Protocols and Data are stored cryptographically in a blockchain
  • The cryptographic tokens are used for rewarding network users as well as for application access.
  • Tokens are generated using an algorithm that encourages contribution by members of the network to the system.

What is blockchain?

First and foremost, Blockchain is a public electronic ledger that can be openly shared among disparate users and that creates an unchangeable record of their transactions, each one time-stamped and linked to the previous one. Each digital record or transaction in the thread is called a block (hence the name), and it allows either an open or controlled set of users to participate in the electronic ledger. Each block is linked to a specific participant.

Blockchain can only be updated by consensus between participants in the system, and when new data is entered, it can never be erased. The blockchain contains a true and verifiable record of each and every transaction ever made in the system.

What is Ethereum?

At its simplest, Ethereum is an open software platform based on blockchain technology that enables developers to build and deploy decentralized applications. In the Ethereum blockchain, instead of mining for bitcoin, miners work to earn Ether, a type of crypto token that fuels the network. Beyond a tradeable cryptocurrency, Ether is also used by application developers to pay for transaction fees and services on the Ethereum network.

What is Smart Contract?

Smart contract is just a phrase used to describe computer code that can facilitate the exchange of money, content, property, shares, or anything of value. When running on the blockchain a smart contract becomes like a self-operating computer program that automatically executes when specific conditions are met. Because smart contracts run on the blockchain, they run exactly as programmed without any possibility of censorship, downtime, fraud or third party interference.

In this guide, we will learn how to deploy an Ethereum smart contract on blockchain and build application around it. We will be making a lottery app which enables players to bet their own ether in the lottery, and the winner of the lottery gets all the ether as prize.

We will not be deploying this app on real ethereum network as it costs real ethers. Instead, we will use Rinkeby test network, which is a test network and ethers present in it are not real traded cryptocurrency, thus making it ideal for testing purposes.

We will be using React framework for app development, and nodejs for testing and deployment of contract, while the contract itself will be coded using solidity, which is a programming language exclusively used for smart contract development.

First of all you have to install metamask, which is a handy chrome extension used to create and manage accounts over the ethereum network. Download it from metamask.io After installing it, create a new account in metamask, by providing an email id and password. After successful creation, metamask will generate a 12 word mnemonic for you which can be used for authentication purposes, so be sure to paste that mnemonic somewhere safe, as we will need it later.

Now your metamask window might look like this:

metamask main create account

First click on top left drop down menu (circled in red) and switch to rinkeby test network. Then click on top right menu (circled in blue) and click on ‘create account’. This will create a new account which can be used to perform transactions. You will see your account address in the main window which you can copy to clipboard via “” button adjacent to account info.

Now to add test ethers to this rinkeby account, visit any online faucet like: faucet.rinkeby.io and follow the instructions given there. You will be then given 20 ethers in your rinkeby account, (these ethers are valid only over rinkeby network, and not actual ethereum network).

You can make few more accounts and add ethers to them using above procedure.

We will continue further in part 2…

Read Part 2 here.

One Reply to “Intro to Ethereum: Deploy a lottery app on blockchain. (part 1)”

Leave a Reply

Your email address will not be published. Required fields are marked *