After the political unrest in Catalonia, Spain, where voting for the independence referendum was disrupted by police, we decided that the polling system of today needs a dramatic overhaul. Traditional voting systems are 1) centralized, 2) non-anonymous, and 3) vulnerable to fraud. Blockchain technology, especially Ethereum smart contracts, present the perfect solution to these problems. Thus, we set off on constructing a framework that enables groups to hold open-source, yet perfectly anonymous and secure polling systems.
What it does
DeVote provides the base code for anyone seeking to host a free, fair, and anonymous vote. Through our simple interface, the complex task of writing a smart contract and interfacing with the Ethereum blockchain can be greatly simplified. Through our framework, anyone can set up an election, defining the candidates running for election and the valid Ethereum addresses that are allowed to vote. This accomplishes a few major tasks. First off, by defining which addresses are allowed to submit votes, we can separate valid voters from invalid voters. Secondly, instead of tying one vote to one name (which poses issues in politically unstable environments), voting is completely anonymous. After an address has voted, its value is discarded, so the the anonymity of the vote sender is preserved. Finally, since all votes are tallied by each node in the blockchain, the vote count is confirmed through consensus. This removes any chance of fraud in the counting of votes (think Florida circa. 2000), and results are immediate and public.
This avoids the pitfalls of traditional voting systems. When an election is controlled by a single polling entity (generally the state), we trust the entity to count the votes, validate who's allowed to vote, and keep the vote of each individual secret. In many cases, this trust does not exist. DeVote is targeted at areas that would benefit greatly from decentralized voting systems, one that is decentralized, open-source, secure, and anonymous.
How we built it
Our framework can be broken down into two major components: backend, which is served by a Solidity smart contract running the Ethereum Virtual Machine, and frontend, which uses the web3 API to communicate with the blockchain to read and write data.
The backend is ran by the EVM, which means its execution is done over the entire Ethereum blockchain. This accomplishes the goal of decentralization we set forth in our vision. Meanwhile, the frontend loads candidate data and also sends votes to the Ethereum nodes. Since DeVote requires Ether (gas) to process modifications to the data on the blockchain, apps built on DeVote require the use of Ethereum browsers. The simplest choice is MetaMask, a Google Chrome extension that can handle all Ether functions.
The website (temporarily hosted on michaelman.net), is a sample client built with DeVote. We set up an election for the next president of Princeton, and accept votes from a predefined set of addresses.
Challenges we ran into
The biggest challenge for the team was probably getting accustomed to the technologies we were using. While the team had at least basic knowledge of the functions of blockchain, none of us had ever developed for it before, so learning the tools we were using (Solidity, Truffle, working with smart contracts) was a challenge.
Furthermore, debugging these technologies (specifically with MetaMask, a browser extension that our web app implements) was tedious and seemingly never straightforward, as we still had to access the blockchain to debug.
Finally, for the final step of syncing up with Ethereum to make our website live and fully functional, the task of actually syncing turned out to be a lot more time consuming and buggy than we anticipated.
Accomplishments that we're proud of
We are proud that we successfully navigated the complex nature of building decentralized applications, and we are very happy to have our smart contract being executed on the Ethereum blockchain.
What we learned
We learned how to write smart contracts in Solidity and deploy them to the Ethereum blockchain. Furthermore, writing our frontend code helped us better understand how to structure asynchronous API calls and create callback functions to process the data from the EVM.
What's next for DeVote
As for short term goals, we want to further develop this framework so that it's even more intuitive to use, holds less dependencies, and optimize it further for mobile platforms. In the long term, we aim to implement this technology in large government-sponsored elections, especially in politically unstable areas, in order to meet the initial vision of the project.