Created
May 25, 2020 08:42
-
-
Save Ivshti/593c3aeda0f4adf5e77b9ea1875fd9b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| // WARNING: run with NODE_ENV=production for mainnet results! | |
| const ethers = require('ethers') | |
| const FactoryABI = require('adex-protocol-eth/abi/IdentityFactory') | |
| const { provider, providerLogs } = require('../services/eth/provider') | |
| const cfg = require('../cfg') | |
| const ERC20ABI = require('../abi/ERC20') | |
| const Factory = new ethers.Contract(cfg.identityFactoryAddr, FactoryABI, providerLogs) | |
| const Token = new ethers.Contract('0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359', ERC20ABI, provider) | |
| const { bigNumberify } = require('ethers').utils | |
| providerLogs.getLogs({ fromBlock: 0, ...Factory.filters.LogDeployed(null, null) }) | |
| .then(async logs => { | |
| const parsed = logs | |
| .map(log => Factory.interface.parseLog(log).values) | |
| for (const addr of parsed.map(x => x.addr)) { | |
| const amnt = await Token.balanceOf(addr) | |
| if (amnt.gt(bigNumberify(0))) { | |
| console.log(addr+','+(amnt.toString(10)/(10**18)).toFixed(2)) | |
| } | |
| } | |
| process.exit(0) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment