Form groups of 3 to 5 students Develop and run scripts for “Ballot.sol” within your group to give voting rights, casting votes, delegating votes and querying results Write a report with each function execution and the transaction hash, if successful, or the revert reason, if failed Submit your code in a github repository in the form.
yarn install
yarn hardhat compile
yarn hardhat test
First, put your .env file at root. It should contain:
CONTRACT_ADDRESS=
CHAIRPERSON_PRIVATE_KEY=
VOTER_PRIVATE_KEY=
VOTER_DELEGATES_PRIVATE_KEY=
INFURA_API_KEY=
INFURA_API_SECRET=
ALCHEMY_API_KEY=
ETHERSCAN_API_KEY=
To run script, pass desired proposals as arguments:
yarn run ts-node --files ./scripts/Deployment.ts "Proposal 1" "Proposal 2" "Proposal 3"
Now, grab returned contract address and add it to .env inside CONTRACT_ADDRESS=
To run script, pass desired address as argument:
yarn run ts-node --files ./scripts/GiveRightToVote.ts "address voter"
yarn run ts-node --files ./scripts/GiveRightToVote.ts "address voter delegates"
To run script, pass desired address as argument:
yarn run ts-node --files ./scripts/Delegate.ts "address voter"
To run script, pass desired proposal number as argument:
yarn run ts-node --files ./scripts/Vote.ts "number"
To run script, run following command with no arguments:
yarn run ts-node --files ./scripts/WinningProposalAndWinnerName.ts