Inspiration

I wanted to dive deep into compact and built an app this weekend that i have saved for the Midnight Hackathon

What it does

The app let's you create a poll and share it with others through link. It lets people vote on a poll anonymously using zero-knowledge proofs which is powered by Midnight.

How I built it - First, indexer, postgres instance, midnight node and proof server were ran in docker locally. Then, circuits were written in Compact which were the main foundation to creating a poll, casting vote, closing poll and maintaining the total votes. Then, hono backend was written that has a single wallet that pays for transaction. Frontend talks to this backend and backend does everything from creating a transaction, to generating proofs from proof server to sending transaction to Midnight node. The flow is -> Frontend -> Backend -> Talks to proof server to generate zk-proofs <-> Backend then use the wallet to build a transaction to send it to Midnight node -> once proof is verified, the desired operation is performed, like storing poll or changing the ledger state of the votes., etc. We also polled indexer from frontend every 3 seconds to get the the latest block's transactions which is shown in react app on-chain explorer route.

Challenges I ran into - I am writing Compact language after a year so that was a bit of challenge in starting to pick it up again. AI integrated inside Midnight Docs helped a lot. I also ran into compact compiling issues due to some syntax errors and getting this logic work took me some time. Also this is a full stack app so it was challenging to make each piece run together correctly especially backend with compiled circuits. I took help from template repos in Midnight docs.

Accomplishments that I am proud of - I am proud that i am taking production knowledge from here on how to build zero-knowledge applications.

What I learned - I learned Compact, Hono and ton of stuff about Midnight.

What's next for Votin - I will release this app out in public for everyone's use. Will make it really simple that even Web2 users can use it easily. Like, i have done here where wallet is already in backend which pays for users transactions. Will work on it after hackathon too.

Built With

Share this project:

Updates

Submission history