Skip to main content

Welcome to the Election workshop

The Election application workshop consists of several self-paced tutorials with content and coding challenges to help you learn about how to build decentralized applications for the Kadena network using the Pact smart contract programming language, Kadena client libraries, and related developer tools.

What you'll build

The tutorials in the workshop will guide you to create an application website where Kadena community members can vote for nominated candidates or governance proposals placed on a fictional ballot.

In this application:

  • Members of the Kadena community can cast one and only one vote.
  • All votes and vote-counting mechanics must be published on the blockchain, so that the election process is fully transparent.
  • Anyone—inside of the community or outside of it—must be able check the election results and verify that the election process was conducted fairly. For example, anyone should be able to verify that no double or fraudulent votes were cast.
  • All voters must be able to cast their votes anonymously so their privacy is protected.
  • Only the official election administrative account can place candidates or proposals on the ballot.

To ensure that the application can meet these requirements, every vote is executed as a transaction on a blockchain. The blockchain is the perfect vehicle for this type of application because it can ensure data integrity, authenticity, transparency, and privacy. However, transactions require computational resources and fees to be paid in exchange for the resources consumed to validate a block. To make the election application accessible to all community members for free, the election contract includes a special type of reserve account—called a gas station—that pays the fees for all voting transactions.

What you'll learn

By completing the tutorials in this workshop, you’ll learn how to:

  • Create and fund accounts.
  • Leverage keysets and capabilities to manage permissions.
  • Interact with the blockchain directly from your contract code.
  • Read data from the blockchain state for free.
  • Sign and send transactions that require fee payments.
  • Deploy and update a smart contract.
  • Use a gas station to pay fees on behalf of application users.

Some of the topics covered in this workshop are similar to topics introduced in the Quick start or in other parts of the documentation. For example, the workshop requires you to set up a development network on your local computer so that you can construct, sign, and submit transactions that are executed on a Chainweb node. However, the tutorials in the workshop also touch on additional and more specific topics such as:

  • Controlling access to restricted functions using a capability.
  • Updating a deployed contract.
  • Adding unit tests to verify features.

What you'll need

To complete the tutorials in the workshop, you need to have some software installed on the computer you are using for your development environment. Each tutorial includes a "Before you begin" summary of what you'll need for that specific tutorial. As a preview before you start the workshop, you should check whether your development environment meets the following basic requirements:

  • You have an internet connection and a web browser installed on your local computer.
  • You have a code editor, such as Visual Studio Code, access to an interactive terminal shell, and are generally familiar with using command-line programs.
  • You have Docker installed and are generally familiar with using Docker commands for containerized applications.
  • You have Git installed and are generally familiar with using git commands.
  • You have Pact and the Pact language server plugin installed on your local computer.
  • You have Node.js and npm installed on your local computer.
  • You have access to the Kadena CLI or Chainweaver desktop or web application. Note that you can perform all of the tasks in the tutorials by using API calls instead of Kadena CLI or [Chainweaver]. However, step-by-step workshop examples illustrate using those tools for simplicity and convenience.

If you have everything you need, you're ready to start building the election website by following the workshop roadmap.

Workshop roadmap

This workshop consists of multiple tutorials that you should complete in order. Each tutorial provides some starter code and guides you to completing the tasks necessary to build the Election application to run on the Kadena blockchain.

For the first tutorial, you'll clone a repository with a working frontend for the election application website that stores candidates and votes in memory. After that, you'll set up a local development network and your development workspace to begin building the blockchain backend for the election website. The workshop repository contains branches with starter code for every tutorial, so you can compare your solution with the finished code at every step along the way.

The workshop is divided into the following sections:

To suggest topics you'd like to see covered in future tutorials and workshops, submit a documentation request. If you'd like to contribute content—either in the form of a new tutorial or to fix issues—see the contributor's guide.