Video Demo & Explanation of the Dapp: https://www.youtube.com/watch?v=T7MAnco-XBY Source Code: https://github.com/peppersec/_ERC20_voting_app_ETH_NY
Any ERC20 token should have the governance!
What it does
It allows anyone to create a ballot for current token holders for any ERC20 token.
How we built it
We used Solidity, Js, Merkle trees, thegraph.com, thundercore and skale.com Basically, we create a token cap table by using Transfer event for ERC20 token and calculate the balances for each token holder. Once it's done, we create a merkle tree and deploy smart contract with merkle tree root hash. Then anyone can cast a vote using the frontend UI if the voter is in the snapshot that was taken at particular block number.
Challenges we ran into
We used ZRX token as an example and it had 900,000 Transfer events and it took some time to process this large amount of data to generate token cap table. Right now, it's a bit slow because the cap table consist of 90,000 token holders and for the demo purpose we had to cut the list down to 30,000 because the merkletree.js library is very slow to generate merkle proof out of this list. One of the optimization that could be done is to pregenerate the merkle proof for every token holder to speed it up OR to rewrite merkletree.js library
Accomplishments that we're proud of
- Protection from double voting
- Very cheap deployment comparing to Aragon
- Aragon doen't provide tools for generating cap table
- aragon forces you to upload whole token cap table into a smart contract which can be very expensive
- Trustless, verifiable, provable approach
- Anyone can create such ballot even if you are not a token holder
- Doesn't require to have any special token. It works for any compliant ERC20 token that was deployed at anytime.
What we learned
Some tokens like ZRX has a bug for minting tokens. It didn't follow the ERC20 when the ZRX was deployed to emit Transfer event from 0x00..000 address which makes the calculation of token cap table a bit tricky. How to use massive amount of data for very cheap price in solidity
What's next for ERC20 Voting app
Make it faster to generate merkle proof Automate creation of smart contract deployment, pregenerating merkle tree root hash.