Learning to use ERC20 EIP standard and Open Zeppelin contracts implementing a tokenized ballot.
Put your .env file at root. It should contain:
ERC20_TOKEN_DEPLOYER_PRIVATE_KEY=
VOTER1_PRIVATE_KEY=
VOTER2_PRIVATE_KEY=
VOTER1_PUBLIC_KEY=
VOTER2_PUBLIC_KEY=
ERC20_TOKEN_CONTRACT_ADDRESS=
TOKENIZED_BALLOT_CONTRACT_ADDRESS=
INFURA_API_KEY=
INFURA_API_SECRET=
ALCHEMY_API_KEY=
ETHERSCAN_API_KEY=
Install dependencies
yarn install
Compile contracts
yarn hardhat compile
yarn hardhat test
Single execution of all the workflow inside hre with hardcoded values.
yarn run ts-node --files ./scripts/hre/Main.ts
In order to properly deploy to Goerli, you need to have a funded account. You can get some Goerli ETH a Goerli Faucet. Once an account is funded with Goerli ETH, you can deploy the contracts to Goerli by running the following commands in this order:
Deploy VotingERC20Token as deployer/minter - needed for users to get voting tokens and voting power
yarn run ts-node --files ./scripts/goerli/DeployVotingToken.ts
Mint desired amount of tokens for Voter1 and Voter2.
yarn run ts-node --files ./scripts/goerli/MintVotingToken.ts "amount"
Voter 1 delegates voting power to Voter 2. Also Voter 2 self-delegates to activate vote power.
yarn run ts-node --files ./scripts/goerli/DelegateVotingToken.ts "Voter2 address"
Deploy Tokenized Ballot as deployer. Will set BlockId as latest. Pass desired proposals as arguments.
yarn run ts-node --files ./scripts/goerli/DeployTokenizedBallot.ts "Proposal 1" "Proposal 2" "Proposal 3"
Voter 2 votes certain amount to desired proposal number.
yarn run ts-node --files ./scripts/goerli/Vote.ts "proposal" "amount"
Voter 2 certain amount to desired proposal number.
yarn run ts-node --files ./scripts/goerli/Vote.ts "proposal" "amount"
Check who's winning on current block.
yarn run ts-node --files ./scripts/goerli/WinnerName.ts