We will be creating a simple poll application, in which a user can sign in, create polls, cast votes and see voting results. Creating a poll will cost 200 tokens, voting is free, and both actions will be available only for signed in users.

For this tutorial we will be using Starport, an easy to use tool for building blockchains. Install Starport and run the following command to create a voter project:

starport app

Starport app command will scaffold a project structure for your application in a voter directory. Make sure to replace alice with your GitHub username.

Inside the voter directory we can see several files and directories:

Our project's directory contains all the code required to build and launch a blockchain-based app. Let's try launching our app by running starport serve inside our project:

starport serve
📦 Installing dependencies...
🚧 Building the application...
💫 Initializing the chain...
🙂 Created an account. Password (mnemonic): truth tooth front fabric sing divert zone milk fatigue urban hundred certain sorry merge milk treat foam coral absent run stand invest monkey aspect
🙂 Created an account. Password (mnemonic): famous faculty genre finger build fantasy squirrel icon carbon absent sleep weather fold piece thank earth pioneer excite trim cupboard grow pumpkin bundle auction
🌍 Running a Cosmos 'voter' app with Tendermint.

🚀 Get started: <http://localhost:12345/>

Congratulations! You now have a blockchain application running on your machine in just two commands. It doesn't do anything yet, so let's work on that.

Our voting applications has two types of entities: polls and votes. A poll is a type that has a title and a list of options.

Adding polls

starport type poll title options

This command generated code that handles creation of poll items. If we now run starport serve and visit http://localhost:8080 we will see a form for creating polls. It may take a short while to rebuild the app, so give it a couple of seconds.

Sign in with one of the passwords printed in the console and try creating a poll. You should see a new object created and displayed above the form. You have successfully created an object and stored it on the blockchain!