Created
July 26, 2023 03:36
-
-
Save nhancv/007118596fcededef03d3aa1c4099834 to your computer and use it in GitHub Desktop.
Export NFT ids of owner to text file
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 fs = require('fs'); | |
const fetchNFTIDs = async () => { | |
const NFT_ADDRESS=''; | |
const OWNER_ADDRESS=''; | |
const ETHERSCAN_APIKEY=''; | |
const res = await fetch(`https://api.etherscan.io/api?module=account&action=addresstokennftinventory&address=${OWNER_ADDRESS}&contractaddress=${NFT_ADDRESS}&page=1&offset=1000&apikey=${ETHERSCAN_APIKEY}`); | |
if (res.ok) { | |
const data = await res.json(); | |
const file = `nfts-${OWNER_ADDRESS}-${Date.now()}.txt`; | |
console.log(`Writing ${data.result.length} NFTs to file ${file}`); | |
fs.writeFileSync(file, JSON.stringify(data.result.map(v => v.TokenId))); | |
console.log('Done.'); | |
} | |
}; | |
fetchNFTIDs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment