The Cardano Ballot: developing a decentralized voting app

18 October 2022 • News
Thomas A. Mayfield
Blockchain Engineer

A decentralized voting app enabling every vote verified on-chain, and showcasing the advantages and potential of the Cardano blockchain

Multiple moving parts are involved in preparing an international event such as the Cardano Summit 2022, with various teams tending to different aspects in order to ensure things will run as smoothly as possible. In late July, the Metadata Tools team of Cardano Foundation received a new task: Support the Summit through the development of a voting application that anyone could easily use. The app should also both leverage the possibilities of the Cardano blockchain and have every vote verified on-chain.

With only two months to develop an elegant and fully functional solution, the Metadata Tools team started a period of intense work and discovery. Today, the team, along with the entire Cardano Foundation, is delighted to introduce the Cardano Ballot

Laying the foundations for a voting app

The main requirements for the Cardano Ballot implied an application that not only served the Cardano Summit but also showcased the advantages as well as the potential of the Cardano blockchain. It needed to be designed and built in a way that would enable everyone to vote for the community-chosen speaker and award Summit nominees. Voting was also to be provided at no-cost to users and have a limit of one vote per user.

The Metadata Tools team considered numerous design models, some utilizing metadata transactions, others using native assets, smart contracts, or the Hydra scalability solution. The option of repurposing existing Cardano voting solutions was also contemplated.

We quickly identified an inability to rely on weighted voting models that are based on the amount of staked ada. We needed to ensure an equal voting weight per user and these models naturally could not provide such a guarantee. Moreover, the team discovered some difficulty in limiting one wallet to one vote.

The development process saw the Cardano Ballot evolve into a Web3 voting application that employed the Cardano Foundation’s new open source Wallet Connector, enabling users to connect a Cardano Wallet supporting CIP 30 and CIP 8 standards. The team implemented two distinct methods for verifying a user’s wallet: either resorting to a Discord bot, or to an SMS message. Leveraging the CIP 8 message signing and the wallet’s stake address, we required users to sign a secret message provided via one of the two methods, thus authenticating the ownership of the connected wallet.

The decision to develop this new Wallet Connector library was two fold. First and foremost, we required a solution for the Cardano Ballot and, through significant trial and error, we discovered numerous issues across various wallet projects related to wallet connection that meant we would not derive an optimal use from them. Secondly, the team wanted to offer to future Cardano developers an open source solution that removed the probable workload and burden associated with the problems as they currently stand.

Fostering open source tools and optimizing utility

In addition to the identified wallet issues, the open source Wallet Connector library sought to provide a light-weight solution not reliant on existing serialization libraries. Therefore, we developed the bespoke React component to provide functionality that prioritizes wallet connection and CIP 8 message signing. The final result was an open source wallet connector enabling any developer or project to introduce Cardano wallet connection and authentication seamlessly. We hope this new Wallet Connector enhances the Cardano developer journey and helps overcome the limited standardization in wallet connection buttons and components encountered by our team. 

With a connected and verified Cardano wallet, the user can now draft a Cardano Ballot for the various nominees in the Summit’s different speaker and award categories. A Cardano Ballot draft must also be signed using the CIP 8 standard, at which point it can then be submitted as a vote. In this way, the app utilizes CIP 8 to both verify a connected wallet and sign a drafted ballot. The team also resorted to CIP 8 in order to create a sign-in feature for the application.

Throughout the process of developing and implementing the open source Wallet Connector, it became apparent that present mobile device support in the Cardano ecosystem is significantly limited. Furthermore, there exists some considerable variation in how the CIP 8 standard is implemented across different wallets.

Going forth, the Cardano Foundation also intends to release an open source JAVA CIP 8 verifier and parser that can be incorporated into Cardano projects. This JAVA CIP 8 verifier and parser enables deserialization of CIP 8 signatures and is specifically designed to support the data extraction workflows for SundaeSwap Governance. Likewise, the library supports the generalization of CIP 8 signature parsing using the popular JAVA programming language.

Having the vote on-chain

Once the Cardano Ballot had been signed and submitted to the system, the team then faced the challenge of deciding what would provide an ideal option to write the vote on-chain. The method chosen would have to encompass a number of considerations, including a focus on transparency and verification, as well as on a responsible use of the blockchain.

Some ongoing discussions have debated whether a blockchain’s main network—frequently referred to as layer-1—should be utilized as a database. In the case of the Cardano Ballot, this would mean having all signed ballots written on-chain. It would certainly provide the desired transparency and verification characteristics, but it also raised concerns.

With an understanding of merkle trees and their significance to verification, the team set upon identifying a responsible solution that offered transparency and verification, whilst not utilizing Cardano’s layer-1 as a database. Conversations with different community-owned projects began during this combined phase of design and development.

In meeting with Voteaire, and even though the team identified numerous use-cases where the project presented an ideal solution, it became clear that integration with their voting solution would require writing all votes on-chain and so did not match our requirements. Some existing issues with ensuring one vote per user also arose. Nonetheless, discussions with Voteaire proved invaluable. They delved into crucial information about the existing issues with decentralized voting and with providing verifiable solutions to users in a cost effective way.

SundaeSwap, on the other hand, has recently implemented a governance model that employs merkle trees as a means to verify data and that does so without writing the entire data onto the Cardano blockchain. The insightful discussions with SundaeSwap, along with their willingness to share the invaluable lessons they learned while developing their solution, allowed us to identify a viable solution for the Cardano Ballot’s verification mechanism that provided transparency and verification, yet did not require writing highly extensive amounts of data on-chain. In addition, it did so at a minimal cost.

This partnership with SundaeSwap also comes as an instance of the Cardano Foundation’s collaborative work with the Cardano community. It is part of the Foundation’s constant efforts to both showcase and aid the ecosystem’s maturity.

From the Cardano Ballot to blockchain utility

In the journey to design and develop the Cardano Ballot, the Metadata Tools team encountered both commendable aspects within the Cardano development ecosystem and areas that could benefit from further exploration and development. With a desire to continue collaborative work with the ecosystem, we are now documenting and analyzing potential paths for improving the Cardano developer and user experience.

Although the Cardano Ballot was designed specifically for the Cardano Summit 2022, it prompted discussions surrounding an enterprise-grade solution and what would be required to implement it. Both the Cardano Foundation at large and the Metadata Tools team in particular know of the growing research and development into self-sovereign identity (SSI). We are equally aware of the issuance of decentralized identifiers (DIDs) on Cardano with projects such as Atala Prism, RootsID, IAMX, and Sidetree-Cardano. Moreover, numerous standards and systems that exist within SSI—such as DIF, W3, Trust Over IP, KERI—should receive consideration if the goal is to design and develop a truly interoperable identity solution.

The Cardano Ballot will ultimately be refactored into an open source library. We hope it will become useful to others within the community and for purposes beyond those of the Cardano Summit 2022.

This development project provided an eye-opening experience for the team as we identified areas in the Cardano developer journey that require further discussion. It is with this in mind that the Cardano Foundation plans to conduct a Wallet Connector and DApp workshop at the Cardano Summit 2022, as well hosting discussions surrounding CIP standards, decentralized voting, and more.

The Metadata Tools team and the Cardano Foundation invite the full Cardano community to vote first for speaker categories and later for the inaugural Cardano Summit Awards. We also hope to see everyone either in-person or virtually at the Summit, and look forward to continuing to collaborate with the Cardano community.