ERC20Votes properties
Snapshots
Creating snapshots when supply changes
Using snapshots
Self delegation
Contract overall operation
-There's a contract MyToken.sol and you can run "npx hardhat compile"
-There's a script TestMyToken.ts and you can "npx hardhat run ./scripts/TestMyToken.ts"
-copy all files/folders from voting-contract except artifacts, cache, node_modules
-create new tokenized-ballot and paste here
-make sure you have the .env file (.gitignore it)
create a scripts folder under the root tokenized-ballot folder & then create a TestMyToken.ts file under scripts directory
-don't forget to npm i @openzeppelin/contracts
==============================================
The easiest way is to run the CheckVoter.ts script below to check if the address has a voting right/weight, the address has already voted, etc:
npx ts-node --files ./scripts/CheckVoter.ts [contractAddress] [address1]
Sample contract: https://sepolia.etherscan.io/address/0x329590c91563584091f6f4d8909728eb1050efec
You can also run the PrintResults.ts script below to check the result of votes:
npx ts-node --files ./scripts/PrintResults.ts 0x329590c91563584091f6f4d8909728eb1050efec 3
To deploy a new contract you can run the DeployWithViem.ts script below:
npx ts-node --files ./scripts/DeployWithViem.ts
npx ts-node --files ./scripts/DeployWithViem.ts ramen pizza burger
npx ts-node --files ./scripts/DeployMyToken.ts
npx ts-node --files ./scripts/GrantMinterRole.ts CONTRACT MINTER_ADDRESS
npx ts-node --files ./scripts/MintTokens.ts CONTRACT TO_ADDRESS AMOUNT
npx ts-node --files ./scripts/TransferTokens.ts CONTRACT_ADDRESS TO_ADDRESS AMOUNT
npx ts-node --files ./scripts/DelegateVotes.ts CONTRACT_ADDRESS DELEGATE_ADDRESS
npx ts-node --files ./scripts/ViewTokenStatus.ts CONTRACT_ADDRESS ACCOUNT_ADDRESS
*Target block determines voting power/delegation
npx ts-node --files ./scripts/DeployTokenizedBallot.ts TOKEN_CONTRACT TARGET_BLOCK_NUMBER PROPOSAL_NAMES
*Proposal_Index follows values: 0,1,2… *Use Ballot Contract Address
npx ts-node --files ./scripts/CastVote.ts CONTRACT_ADDRESS PROPOSAL_INDEX AMOUNT
npx ts-node --files ./scripts/ViewVotingStatus.ts CONTRACT_ADDRESS ACCOUNT_ADDRESS
npx ts-node --files ./scripts/ViewProposalStatus.ts CONTRACT_ADDRESS
-copy all files/folders from project2 except artifacts, cache, node_modules
-create new project3 and paste here
-make sure you have the .env file (.gitignore it)
create a scripts folder under the root project4 folder & then create a DeployWithHardhat.ts file under scripts directory
nvm use --lts
node -v
v20.14.0
Unique id | Discord username |
---|---|
RAAzLF | @GRAVER 👾 |
2SyBp0 | @wackozacco |
10exgX | @δαλλασκατ |
r5YSqY | @imchrismayfield |
HhHAQw | @swooz |
Pok9XD | @Timster |
T5zGzt | @Carl Youngblood |
Please check into CONTRACT INTERACTION REPORT
npm init
npm install --save-dev hardhat
npx hardhat init
-> Create a typescript project
npx hardhat compile
npx hardhat test
npx hardhat clean
cretae a .mocharc.json with contents:
{
"require": "hardhat/register",
"timeout": 40000,
"_": ["test*/**/*.ts"]
}
rm ./contracts/*
rm ./ignition/*
rm ./test/*
npx hardhat clean
npm i viem
npm install --save-dev @nomicfoundation/hardhat-chai-matchers