A blockchain solution to Maine state ranked voting system.
Refer the project report for the walk-through and the instructions.
MSRVE_Ballot.sol is available in MSRVE-Ballot-Dapp/ballot-contract/contract
- Clone repo and enter folder MSRVE-Ballot-Dapp.
- Run command
npm run setupto install all required node modules at their appropriate locations.- Alternatively, navigate to folders ballot-app and ballot-contract and run command npm install at both locations.
- Open Ganache GUI. Initiate a developement blockchain.
- Navigate to folder MSRVE-Ballot-Dapp/ballot-contract/migrations and modify JavaScript files by replacing the address there with the address of admin account (the address of the last user from Ganache GUI).
- Run command
npm startin folder MSRVE-Ballot-Dapp/ballot-contract which shall compile and migrate the Smart Contract. - For Windows users, ip.sh file in ballot-app folder will need to be changed as this repo was developed in Ubuntu. This file is a work around.
- Run command npm run demo in folder MSRVE-Ballot-Dapp or MSRVE-Ballot-Dapp/ballot-app to start the demo run.
- Navigate to MSRVE-Ballot-Dapp/ballot-contract and run command
npm start. - Navigate to MSRVE-Ballot-Dapp/ballot-app and run command
npm start.
- To use the testing framework and test the Smart Contract, run command
npm testin folder MSRVE-Ballot-Dapp or MSRVE-Ballot-Dapp/ballot-contract to start the test run.
To change states and to trigger the final vote calculation, run the following steps:
- Navigate to MSRVE-Ballot-Dapp/ballot-contract and run command
truffle console. Run all following commands in this console. Note: It is assumed that the admin is set as the last user from the Ganache user list as stated in Step 4 of Setup. - Enter command var ballot = await MSRVE Ballot.deployed() to get the deployed contract.
- Enter command var acc = await web3.eth.getAccounts() to get the accounts available in Ganache.
- To change the Smart Contract state, run command
ballot.changeState(\<state>, from:acc[9]), where <state> is the new state. 0 is for Registration, 1 for Voting and 2 for Done state. - To calculate the final winner, run command
ballot.calcWinner(from:acc[9]).