Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcspark/plutus-voting-dapp
A smart contract which enables users to vote for spending funds from a treasury UTXO.
https://github.com/dcspark/plutus-voting-dapp
Last synced: about 1 month ago
JSON representation
A smart contract which enables users to vote for spending funds from a treasury UTXO.
- Host: GitHub
- URL: https://github.com/dcspark/plutus-voting-dapp
- Owner: dcSpark
- License: mit
- Created: 2022-02-01T15:54:56.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-05T08:50:38.000Z (over 2 years ago)
- Last Synced: 2024-04-16T08:55:26.525Z (9 months ago)
- Language: Haskell
- Homepage:
- Size: 30.3 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Plutus Voting Smart ContractA smart contract which enables users to vote for spending funds from a treasury UTXO.
## 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:
0. Preparation steps:
- Mint voting tokens and distribute among participating wallets.1. Set up the treasury:
- Lock tokens in the treasury with the vote configuration (voting token and required quorum)2. Vote for address(es):
- Locks the a number of vote tokens together with a datum containing the voted choice.3. 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.4. 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:
``` bash
$ nix-shell
...
$ cabal build
...
```## Testing
To run use-case test execute the following commands at the project root.
``` bash
$ 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
```