Skip to content

Instantly share code, notes, and snippets.

@Yuripetusko
Forked from stevyhacker/snapshot.js
Last active June 16, 2022 23:55
Show Gist options
  • Save Yuripetusko/f5100cd323b4707a72f83430bcca14f0 to your computer and use it in GitHub Desktop.
Save Yuripetusko/f5100cd323b4707a72f83430bcca14f0 to your computer and use it in GitHub Desktop.
NFT holders snapshot tool
import fetch from 'node-fetch';
import fs from 'fs';
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
const apiKey = "INSERT_YOUR_OWN_API_KEY_HERE"
const collections = [
{name: 'BAYC', address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d'},
{name: 'MAYC', address: '0x60e4d786628fea6478f785a6d7e704777c86a7c6'},
{name: 'Decentraland', address: '0xF87E31492Faf9A91B02Ee0dEAAd50d51d56D5d4d'},
{name: 'Sandbox', address: '0x5CC5B05a8A13E3fBDB0BB9FcCd98D38e50F90c38'},
{name: 'LobsterDAO', address: '0x026224A2940bFE258D0dbE947919B62fE321F042'}
]
const baseURL = `https://eth-mainnet.alchemyapi.io/nft/v2/${apiKey}/getOwnersForCollection`;
collections.forEach(collection => {
const fetchURL = `${baseURL}?contractAddress=${collection.address}`;
fetch(fetchURL, requestOptions)
.then(response => response.json())
.then(response => {
const holders = response.ownerAddresses.map((ownerAddress) => {
return ownerAddress;
});
fs.writeFile("./" + collection.name + "_snapshot.csv", holders.join("\r\n"), (err) => {
console.log(err || "Snapshot for " + collection.name + " saved.");
});
})
.catch(error => console.log('error', error));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment