GithubHelp home page GithubHelp logo

nikhils9 / plutus-voting-dapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dcspark/plutus-voting-dapp

0.0 0.0 0.0 31 KB

A smart contract which enables users to vote for spending funds from a treasury UTXO.

License: MIT License

Haskell 74.78% Nix 25.22%

plutus-voting-dapp's Introduction

Plutus Voting Smart Contract

A smart contract which enables users to vote for spending funds from a treasury UTXO.

license

Disclaimer

The code on this repository has not been audited. We don't recommend it using in production without a full security audit. Use it at your own risk!.

Protocol

This contract allows to pay the content of a treasury to the an address that gets enough votes. A special designated token represents the vote. Depening on the intial voting token distribution, allows different voting power per wallet.

Protocol steps:

  1. Preparation steps:

    • Mint voting tokens and distribute among participating wallets.
  2. Set up the treasury:

    • Lock tokens in the treasury with the vote configuration (voting token and required quorum)
  3. Vote for address(es):

    • Locks the a number of vote tokens together with a datum containing the voted choice.
  4. Tally votes:

    • Tries to collect more utxos with more than the required quorum on a particular choice.
    • If successful, pays the content of the treasury to the winniing address.
  5. Return (or recall) vote

    • At any time, a voter can get back all their votes

Building

To build the project execute cabal build at the project root.

To build:

$ nix-shell
...
$ cabal build
...

Testing

To run use-case test execute the following commands at the project root.

$ cabal test
Build profile: -w ghc-8.10.4.20210212 -O1
In order, the following will be built (use -v for more details):
 - voting-dapp-0.1.0.0 (test:voting-dapp-test) (first run)
Preprocessing test suite 'voting-dapp-test' for voting-dapp-0.1.0.0..
Building test suite 'voting-dapp-test' for voting-dapp-0.1.0.0..
Running 1 test suites...
Test suite voting-dapp-test: RUNNING...
use cases
  Simple endpoint tests
    Expose endpoints:                                                OK
    Build treasury:                                                  OK (0.02s)
    Single vote:                                                     OK (0.04s)
    Return vote:                                                     OK (0.08s)
    Tally votes:                                                     OK (0.12s)
  Voting scenarios
    Voted wallet with quorum should get content of treasury:         OK (0.30s)
    Voted wallets with no quorum should not get content of treasury: OK (0.17s)

All 7 tests passed (0.74s)
Test suite voting-dapp-test: PASS

plutus-voting-dapp's People

Contributors

robkorn avatar leadplutusdev 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.