Git Product home page Git Product logo

substrate-voting's Introduction

substrate-voting

Check Set-Up & Build

This is a substrate proof of concept that includes a custom voting pallet. The voting pallet allows users to cast votes for candidates and retrieve voting results.

Usage

Build

cargo build --release

Run local dev

cargo build --release -- --dev

Connect front end apps

You can interact with it using the hosted version of the Polkadot/Substrate Portal front-end by connecting to the local node endpoint.

You can also use the Substrate Front End Template.

Voting pallet

The voting pallet is a module in the substrate-voting proof of concept that handles the voting functionality. It allows users to cast votes and retrieve voting results.

Storage

HasVoted is a mapping of account addresses to a boolean value indicating whether the corresponding account has voted (true) or not (false).

CandidateVotes is a mapping that associates candidate ids with the number of votes they have received.

Dispatchable functions

vote is a dispatchable function that allows users to cast votes for candidates. It takes a candidate id as an argument and increments the vote count for the candidate.

Events

SomeoneVoted is an event that is emitted when a user casts a vote. It includes the account address of the voter and the candidate id they voted for.

Errors

AlreadyVoted is an error that is returned when a user tries to vote more than once. CandidateNotFound is an error that is returned when a user tries to vote for a candidate that does not exist.

Future work

  • Add more dispatchable functions to allow for more complex voting scenarios.
  • Implement a more sophisticated voting system with multiple rounds of voting.
  • Make the voting secret and anonymous.

substrate-voting's People

Contributors

nuke-web3 avatar jeluard avatar shawntabrizi avatar paritytech-ci avatar matias-gonz avatar joshorndorff avatar danforbes avatar brunopgalvao avatar riusricardo avatar dependabot[bot] avatar anderssorby avatar kaichaosun avatar tripleight avatar sacha-l avatar xlc avatar h4n0 avatar c410-f3r avatar alvicsam avatar chenzongxiong avatar jingnanzhou avatar hamidra avatar gui1117 avatar cab404 avatar vyorkin avatar srslafazan avatar sameerdhoot avatar alfellati avatar mordamax avatar ltfschoen avatar jamesbayly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.