Chapter 12. Putting it all together: Building a complete voting Dapp

 

This chapter covers

  • Designing and implementing a voting contract showcasing most Solidity features, such as modifiers and events
  • Integrating the voting contract in Truffle, for integrated compilation, testing, and deployment
  • Implementing an asynchronous web UI seamlessly connected to the contract through the truffle-contract JavaScript library
  • Deploying onto the public test network from Truffle

In the previous chapter, you started to enjoy the benefits of using Truffle to improve the development lifecycle:

  • Contract compilation became as easy as executing a simple truffle compile command. You didn’t have to instruct the solc compiler explicitly to push its output to specific files to be reused later for deployment.
  • Contract deployment became much easier than you were used to, thanks to Truffle’s migrations functionality based on minimalistic configuration. Truffle did all the hard work of packaging the compilation output and feeding the contract ABI and bytecode to the deployment transaction behind the curtains. No more manual copying and pasting of long text!
  • Also, testing became much simpler than when you performed it through Mocha. You didn’t need complicated initialization to deploy the contract at each test, and you could keep testing logic by writing asynchronous JavaScript based on async/await.

12.1. Defining the requirements of a voting Dapp

12.2. The development plan

12.3. Starting the Truffle project

12.4. Implementing the voting contract

12.5. Compiling and deploying SimpleVoting

12.6. Writing unit tests

12.7. Creating a web UI

12.8. Food for thought

Summary