Educational script to show how to retrieve NFT metadata from ERC-721 contracts.
This was built using Node.js v16.13.1
Clone the repo:
git clone https://github.com/Ty-Sir/nft-sticky-bandits
Move into the correct directory and install dependencies via yarn:
cd nft-sticky-bandits
yarn install
or npm:
cd nft-sticky-bandits
npm install
Go to any of these sites to and sign up for a free account to get a custom RPC Node URL.
Alchemy, Infura, Moralis, or Tatum. Or $9 per month (7-day free trial) at QuickNode.
Open up /src/config.js
and replace const RPC
with the URL you now have from any of those sites.
In the same file, set const address
with the contract address of the ERC-721 NFT collection you would like to learn from.
Then set const collectionSize
with the amount in that collection that you would like to save locally. (The higher the number the longer the retrieval takes)
Finally set const rateLimit
with the rate limit for you custom RPC. If you are unsure set it to 1000 or lower so you do not get timed-out.
Once all the variables in config.js
are set correctly, make sure you're in the nft-sticky-bandits
directory, and in a terminal run:
yarn build
or if npm was used to install run:
npm build
You will see a folder labeled output
appear and two sub-folder labeled images
and json
.
json
will be executed first having all of the tokens metadata in according to its tokenId.
images
will have the image respective to the tokenId.