Working with NFTs
Prerequisite: erc721ABI JSON file
12KB
Retrieve user NFT list
To retrieve all NFTs held in user wallet, you need a third-party tool or API.
In this example, we use Nansen API's GET /address/portfolio endpoint.
const options = {method: 'GET', headers: {accept: 'application/json'}};
fetch('https://api.nansen.ai/v1/address/portfolio', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));Retrieve user NFT details
Once you know the NFT's smart-contract address (using the code above), you can get all its metadata:
Retrieve user NFT balance
This code will allow you to check how many NFTs from a specific collection a user holds.
It is much lighted than the "Retrieve user NFT list" example that uses Nansen shown above.
Last updated