Simple Smart Contract for voting 🗳️, written in PascaLIGO, for Tezos DLT Blockchain ߷⛓️.
Write a smart voting contract (in LIGO):
- 2 vote options possible ("yes" ✔️ or "no" ⛔)
- any user has the right to vote 👩👩👧👦
- a user can only vote once 📌
- the administrator is defined during the deployment of the smart contract 🤴
- the administrator does not have the right to vote 🙅
- the smart contract is paused if at least 10 people have voted
- when the smart contract is paused, the result of the vote must be available (the result is stored in the storage of the smart contract) 💾
- an administrator must be able to reset all votes (and remove the pause => make it active again) 🔁
- the smart contract should have unit tests 📋🧪
First, make sure you have LIGO installed and correctly set up :
Then, copy the contents of this repo and compile, dry-run, and deploy the contract votingContract.ligo
:
ligo compile-contract votingContract.ligo main > votingContract.tz
ligo compile-storage votingContract.ligo main 'record admin = ("tz1LKe9GQfF4wfob11YjH9grP1YdEWZtPe9W": address); paused = False; votes = (map[] : map(address, bool)); end'
ligo compile-parameter votingContract.ligo main "Vote(record vote = False; end)"
ligo compile-parameter votingContract.ligo main "Reset(0)"
pytest pyTestContract.py
No function for returning the value of present votes is implemented yet... coming soon!
Pull requests are always welcome 🤓, though keep in mind this smart contract is more for learning purposes than for commercial use.
For bug fixes or improvements, please open an issue and I will get back to you as soon as I can! 🔜
Please cite the author Charaf ZELLOU and the source tezos-pascaligo-vote repository in any copies, forks or use of the material in this repository.