Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(examples): Voting Realm: A Bitmap and Nonce-based Approach #2225

Draft
wants to merge 55 commits into
base: master
Choose a base branch
from

Conversation

linhpn99
Copy link
Contributor

@linhpn99 linhpn99 commented May 28, 2024

Simple UseCase Description :

1. Initialize the Contract :

  • Call the Init function to set up the contract.
  • This initializes the proposal and voter indices and creates empty AVL trees for proposals and registered voters.

2. Create a Proposal

  • A user creates a proposal by calling CreateProposal with the title, number of participants, and max votes per user.
  • The function returns a unique proposal ID.

3. Register as a Voter

  • Users must register as voters by calling RegisterVoter.
  • Each user receives a unique voter ID upon registration.

4. Cast a Vote

  • Registered voters can cast votes on proposals by calling Vote with the proposal ID and their voter ID.
  • The contract checks if the voter is registered, if the proposal exists, if the proposal is open for voting, and if the voter has not exceeded their vote limit.
  • If all conditions are met, the vote is recorded, and the vote count for the proposal is incremented.

5. Get Vote Count

  • Anyone can check the current vote count for a proposal by calling GetVotes with the proposal ID.
  • The function returns the total votes the proposal has received.

From issue : #2119

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

linhpn99 and others added 30 commits May 16, 2024 14:31
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
@linhpn99 linhpn99 requested review from a team as code owners May 28, 2024 08:53
@linhpn99 linhpn99 requested review from thehowl and mvertes and removed request for a team May 28, 2024 08:53
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label May 28, 2024
@linhpn99 linhpn99 marked this pull request as draft May 28, 2024 08:53
@linhpn99
Copy link
Contributor Author

@moul Here's a simple demo (still under development). I am using newly added packages. Please let me know if anything is unclear

@linhpn99 linhpn99 changed the title Voting Realm: A Bitmap and Nonce-based Approach feat(examples): Voting Realm: A Bitmap and Nonce-based Approach May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant