Created
February 8, 2024 15:54
-
-
Save pogobounce/74e37475b8e5c1e35a5a36b0f6fcb57c to your computer and use it in GitHub Desktop.
Script that snapshots current holders of 2 tokens of more for the original Fingerprints contract
This file contains 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
const { ethers, JsonRpcProvider } = require('ethers'); | |
const fs = require('fs'); | |
const rpcEndpoint = 'https://mainnet.base.org'; | |
const contractAddress = '0xDD2065cB5ef8cb2EAb77027dE85e55AeB31428BD'; | |
const abi = [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"get_owners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"}]; | |
const provider = new JsonRpcProvider(rpcEndpoint); | |
const contract = new ethers.Contract(contractAddress, abi, provider); | |
async function getAddies() { | |
let counts = {}; | |
let uniqAddies = []; | |
let result1 = await contract.get_owners(1,15000); | |
let result2 = await contract.get_owners(15000,30000); | |
for (let i=0; i<result1.length; i++){ | |
if (!uniqAddies.includes(result1[i])) { | |
uniqAddies.push(result1[i]); | |
counts[result1[i]] = 1; | |
} else { | |
counts[result1[i]]++; | |
} | |
} | |
for (let i=0; i<result2.length; i++){ | |
if (!uniqAddies.includes(result2[i])) { | |
uniqAddies.push(result2[i]); | |
counts[result2[i]] = 1; | |
} else { | |
counts[result2[i]]++; | |
} | |
} | |
for (let i=0; i<uniqAddies.length; i++){ | |
counts[uniqAddies[i]] = Math.floor((counts[uniqAddies[i]]) / 2); | |
} | |
let sum = 0; | |
let output = ''; | |
for (let i=0; i<uniqAddies.length; i++){ | |
if (counts[uniqAddies[i]] > 0){ // this can be 0 because we divided by 2 and floored, so discard that case | |
output += `${uniqAddies[i]} ${counts[uniqAddies[i]]}\n`; | |
sum += counts[uniqAddies[i]]; | |
} | |
} | |
console.log("Total nfts to distribute: "+sum) | |
fs.writeFile('snapshot.txt', output, (err) => { | |
if (err) { | |
console.error('Error writing to file:', err); | |
} else { | |
console.log('Data has been written to snapshot.txt'); | |
} | |
}); | |
} | |
getAddies(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0x6A7cbB5F41c972aa1664b0E1E391db9EEcf543c4