- Python 3.8+
- Web3.py
- Access to ethereum node
- List of voters (.csv file) - e.g. all addresses that voted for a specific option
- Node address - URL for Ethereum node RPC calls
- Ethereum block number - block for which the total Voting Power is calculated
-
Install Python >= 3.8: https://www.python.org/downloads/
-
Install web3:
$ pip install web3
-
Get access to ethereum node (e.g. by using https://www.alchemy.com/)
URL may look like this: https://eth-mainnet.alchemyapi.io/v2/AaaAaAAa1AaaaA-1A-AAAAA_AaAA1aaA
Alternative providers of node services: https://ethereum.org/en/developers/docs/nodes-and-clients/nodes-as-a-service/
-
Prepare a list of voters in CSV file format (one address in a row, no header). Save the .csv file in gov-tools directory.
-
Select a block number for which you want to count the total Voting Power.
-
You're all set and ready to launch the script:
$ python count_voting_power.py <file.csv> <HTTP node address> <ethereum block>
Example:
$ python count_voting_power.py voters.csv https://eth-mainnet.alchemyapi.io/v2/AaaAaAAa1AaaaA-1A-AAAAA_AaAA1aaA 13048140