ZkNoid:L1 Lottery

Hi!
Yeah, that would be cool.
Can you contact me (aleksandrivlev) or Andrew (asimaranov) on Discord so we can schedule a call?
We would be more than happy to get some help with reducers and this approach in particular.

1 Like

This application is approved for Funding.

Funding Note: We see this proposal to a useful zkApp to Mina L1. This we see has very high impact in relation to attracting users and increasing protocol usage. Integration with ecosystem partners is very much valued and this can serve as a template for other applications. The builders are part of the ecosystem and have delivered successfully in the past. The risk is classified as Medium because we have identified a potential race issue and have a solution which we are discussing with the team. zkApps dealing with tokens carry an inherent risk. Budget is on the higher side , but the impact justifies the funding decision.

What version of o1js are you planning to use and are you going to use Smart Contract Class?

We are currently using o1js 1.3.1 version. Yes, we are using SmartContract as base class.
Code is open-source, you can check it here GitHub - ZkNoid/L1-lottery: L1-lottery

2 Likes

Progress Update

Two weeks have passed, marking the mid-point milestones.
What we have done during these two weeks:

Smart Contracts

  • Implemented the base version of the lottery contract, which supports ticket purchase and mock random generation.
  • The contract also supports refunds and has a fee mechanism.
  • Covered the contract with tests.
  • Conducted research on reducer applications for future implementation.
  • Contracs located here- GitHub - ZkNoid/L1-lottery: L1-lottery

Design

  • Designed the game page.
  • Created user flows for ticket purchases and reward claims.
  • Designed the appearance of the tickets.

Frontend

  • Developed the first version of the game page.
  • Connected the site to smart contracts.
  • Enabled proof generation for frontend transactions.
  • Frontend located here - GitHub - ZkNoid/zknoid at lottery-o1js

Backend

  • Implemented docker configs for automatic deploy.
  • Implemented a method for faster state fetching.
  • Developed a method for DistributionProof generation and its storage. This proof is shared among all users in a round and requires a significant amount of time to compute in the browser. This drastically improves the user experience by reducing the claim reward proof time.
  • Backend located here - GitHub - ZkNoid/lottery-backend

Future Work:

Smart Contracts

  • Integrate ZkOn VRF.
  • Implement backup random generation. Since the ZkOn VRF timeline is unclear, we plan to implement our own random generation, most likely based on commit-reveal schemes. It won’t be as secure as ZkOn’s solution, but it will serve as a temporary plug until ZkOn’s solution is ready.
  • Implement Action/Reducer. Currently, our contract supports one ticket purchase per block, limiting us to 480 tickets per day and providing a poor user experience. With action reducers, the only limit will be the number of transactions per block.

Design

  • With all the additional work required for the ZKApp to function, such as contract compiling and proof generation, it is easy for users to get lost in the process. Our goal is to create a design that is clear and user-friendly.

Frontend

  • Finish the game page according to the design.

Backend

  • It is challenging to make concurrent reward claims due to parallel nullifier updates and the limit on account updates per transaction. To address this, we plan to implement transaction reordering on the server. This will create transactions based on the predicted contract state and store them until this state is reached.
3 Likes

There is a delay in the delivery of this proposal as the team is awaiting the VRF to be connected to the solution. We are in touch with the team and will update as progress is made.

2 Likes

Glad to say that the milestones depending on us had been successfully delivered in time :tada:!
The lottery game had beed implemented and added to the game store: lottery link

This late message is an overview of the progress achieved within proposal.
We successfully implemented the frontend, backend and contracts sides.

Here is a youtube overview of the working product

The working application required us to implement and connect such parts as smart contracts, design, front-end, back-end. The close interplay of the parts make it possible to wrap ZK technologies into a user friendly application.
The following work involved launching the working zkApp :muscle:

Smart Contracts

These following had been implemented on the contracts side. Contracts are located here located here

  • Implemented the lottery contract, supporting concurrent buys using reducers
  • Support for claims, refunds and a fee mechanism.
  • Contract tests
  • Implemented state manager that is fed with events keeping the offchain state for proofs generation

Design

  • Designed all the proposed pages
  • Implemented illustrations
  • Created all the required userflows and pages.
  • Implemented animations

Frontend

Frontend is located here - here

  • Implemented game frontend
  • Frontend is connected to the smart contracts.
  • Frontend is connected to the Nest JS and trpc api
  • Implemented game frontend

Backend

Backend is here - Nest Js api, trpc api

  • Implemented trpc backend aggregating data for frontend
  • Implemented Nest Js backend containing background workers an claim data fetching
  • Connected backend with mongodb
  • Implemented docker configs for automatic deploy.
  • Wrapped and updated the state manager with correct offchain state.
  • Implemented workers: distribution-proving, produce-result, round-infos-updater, sync-events, empty-ticket-buying, reduce-proving
2 Likes

Great!And when will we play this