Today’s tutorial will show you how to get all verified NFT collections of an address using the Moralis NFT API. Thanks to the accessibility of this API, you can get this data with a single API call to the getWalletNFTCollections()
endpoint. Here’s an example of what it might look like:
const Moralis = require("moralis").default; const { EvmChain } = require("@moralisweb3/common-evm-utils"); const runApp = async () => { await Moralis.start({ apiKey: "YOUR_API_KEY", // ...and any other configuration }); const address = "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326"; const chain = EvmChain.ETHEREUM; const response = await Moralis.EvmApi.nft.getWalletNFTCollections({ address, chain, }); console.log(response.toJSON()); }; runApp();
All you have to do is add your Moralis API key, configure the address
and chain
parameters to fit your query, and run the code. In return, you’ll get a response containing an array of NFT collections.
Each collection will have a verified_collection
property that is either true
or false
. If it’s true
, it means that the NFT collection is verified. Here’s an example of what the response might look like:
//… { "status": "SYNCING", "page": "2", "page_size": "100", "result": { "token_address": "0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB", "contract_type": "ERC721", "name": "CryptoKitties", "symbol": "RARI", "possible_spam": "false", "verified_collection": "false" } } //…
It doesn’t have to be more challenging than this to get verified NFT collections when working with Moralis! If you’d like to learn more about how this works, check out the official get NFT collections by wallet documentation or join us throughout this article.
Also, if you haven’t already, sign up with Moralis immediately, and you’ll be able to make similar calls to the NFT API in a heartbeat!
Overview
The non-fungible token (NFT) space has been growing rapidly over the past few years, and the market is filled with millions and millions of NFT collections. Some are established projects like Pudgy Penguins and CryptoPunks, while others are irrelevant collections and NFT spam. Due to the vast number of projects, you’ll need an easy way to filter out the noise when building NFT projects. Fortunately, this is where the Moralis NFT API enters the equation, allowing you to seamlessly get verified NFT collections with a single line of code. To learn more about how this works, join us in this article as we show you how to get all verified NFT collections of an address in a heartbeat!
We’ll kickstart today’s article by first explaining what verified NFT collections are. In doing so, we’re also going to explain why you need this NFT data when building Web3 projects. From there, we’ll jump straight into the tutorial and show you how to get verified NFT collections in three straightforward steps using Moralis. Lastly, to top things off, we’ll dive into some prominent use cases for verified NFT collections.
What are Verified NFT Collections?
Whenever you query all NFT collections of an address using the Moralis NFT API, you receive an array of collections. Each collection in the array will have a verified_collection
property that will either be true
or false
. If it’s true
, it means that it’s a verified NFT collection.
But what exactly does it mean that a collection is verified?
In short, verified NFT collections are projects that have been vetted by an NFT marketplace. Whenever you see a checkmark next to an NFT collection on websites like OpenSea, Rarible, or Blur, it usually means that the marketplace has verified it.
There are many benefits to having verified NFT collections, and some prominent examples can be found below:
- Visibility: Verified NFT collections can gain more visibility on their respective marketplaces, making it easier for users to find them.
- Trust: Verifying NFT collections brings greater trust to the Web3 ecosystem, allowing users to effortlessly distinguish between legitimate projects and potential scams.
- Scam Detection: By distinguishing between verified and unverified projects, it becomes significantly easier for users to identify potentially fraudulent collections.
All in all, verified NFT collections bring greater trust to the NFT ecosystem by helping community members identify authentic creators and projects. It also helps creators with reach as it makes it easier for users to trust their particular collection.
Why You Need Verified NFT Collections
The NFT market has been growing fast over the past few years, and we have seen millions and millions of collections emerge during this time. This includes legit and verified projects like CryptoPunks, Pudgy Penguins, etc. However, it also includes many unverified projects that are either irrelevant or likely to be scams.
Due to the vast number of projects, you generally need a way to filter out the noise when building an NFT project. In doing so, you’ll be able to present collections that are relevant to your users, providing a more seamless user experience.
If you’d like to learn how to get verified NFT collections using the Moralis NFT API, join us in the next section as we break down the entire process from start to finish!
3-Step Tutorial: How to Get Verified NFT Collections
In the following sections, we’ll show you how to get all verified NFT collections of an address using Moralis. And thanks to the accessibility of the Moralis NFT API, you can now seamlessly get the data you need in three straightforward steps:
- Set Up Moralis
- Create a Script
- Run the Code
However, before jumping into the tutorial, you must complete a few prerequisites!
Prerequisites
In this tutorial, we’ll show you how to get verified NFT collections using JavaScript. As such, before you can continue, you must have the following ready:
With these ready, you’re ready to jump straight into the initial step of the tutorial!
Step 1: Set Up Moralis
In order to call the various endpoints of the NFT API, you initially need a Moralis API key. So, if you haven’t already, click on the ”Start for Free” button at the top right and set up your Moralis account:
With an account at hand, you can head on over to the ”Settings” tab, scroll down to the ”Secrets” section, and copy your API key:
Keep your API key for now, as you’ll need it in the second step of this tutorial to get all verified NFT collections of an address.
Next, you additionally need to install the Moralis SDK. As such, set up a new project in your integrated development environment (IDE), open a new terminal, and run the following command in the root folder:
npm install moralis @moralisweb3/common-evm-utils
That’s it for the first step; you’re now ready to start coding and creating the script for getting verified NFT collections!
Step 2: Create a Script
To get verified NFT collections owned by an address, you simply need a single API call to the getWalletNFTCollections()
endpoint. As such, start by creating a new ”index.js” file in your project’s root folder and add the following code:
const Moralis = require("moralis").default; const { EvmChain } = require("@moralisweb3/common-evm-utils"); const runApp = async () => { await Moralis.start({ apiKey: "YOUR_API_KEY", // ...and any other configuration }); const address = "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326"; const chain = EvmChain.ETHEREUM; const response = await Moralis.EvmApi.nft.getWalletNFTCollections({ address, chain, }); console.log(response.toJSON()); }; runApp();
From here, you now have to make a few configurations to the code. First of all, add the Moralis API key you copied earlier by replacing YOUR_API_KEY
:
Next, configure the address
and chain
parameters to fit your query:
We then pass the parameters above when calling the getWalletNFTCollections()
endpoint:
That’s it for the script; you only need a few lines of code to get verified NFT collections when working with Moralis. From here, all that’s left is running the script!
Step 3: Run the Code
For the final step, open a new terminal, cd
into your project’s root folder, and run the following command:
node index.js
In return for running the code, you’ll get a response containing an array of all NFT collections owned by the address. Each collection in the array has a verified_collection
property that is either set to true
or false
:
//… { "status": "SYNCING", "page": "2", "page_size": "100", "result": { "token_address": "0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB", "contract_type": "ERC721", "name": "CryptoKitties", "symbol": "RARI", "possible_spam": "false", "verified_collection": "false" } } //…
If the verified_collection
property is true
, it means that the collection is verified on OpenSea:
From here, you can seamlessly sort through the array to get all verified NFT collections in a heartbeat!
Congratulations! That’s it; you now know how to get all the verified NFT collections of an address using Moralis!
If you’d like to learn more about why this is helpful, join us in the next section as we explore use cases for when this data can come in handy.
Use Cases for Verified NFT Collections
It doesn’t matter what NFT project you’re building; you’ll quickly realize that you need an easy way to get all verified NFT collections of an address. However, to give you an idea of when this data can come in handy, we’ll give you three examples of use cases for verified NFT collections below:
- NFT Marketplace: An NFT marketplace is a digital platform allowing users to store, sell, buy, display, and sometimes even mint tokens. Some prominent examples of already existing marketplaces include Rarible, OpenSea, and Blur.
When building an NFT marketplace, it can significantly improve the user experience of your application if you let users filter for verified NFT collections. This will help them find legit projects that they can trust.
- Web3 Wallet: Web3 wallets are platforms for storing both fungible and non-fungible assets. Some established actors in the space include MetaMask, Rainbow, and Phantom.
Like when building an NFT marketplace, verified NFT collections can also be helpful when creating a Web3 wallet. For example, a wallet can allow users to manage their verified or unverified assets, which can significantly improve the user experience.
- Portfolio Tracker: Portfolio trackers are financial dashboards for the crypto space. These tools allow you to track your assets across wallets, marketplaces, networks, etc. Some prominent examples include Delta, Kubera, and Moralis Money.
Getting verified NFT collections can also be helpful when building a portfolio tracker. This will allow users only to track relevant assets, as it becomes significantly easier to filter out the noise.
If you’d like to learn more about how you can leverage this data, check out the clip below from the Moralis YouTube channel:
Exploring the Moralis NFT API Further
Fetching all verified NFT collections of an address only scratches the surface of what’s possible with the Moralis NFT API. In fact, this tool provides multiple endpoints for getting all the data you need to build sophisticated NFT projects. As such, let’s briefly explore the ins and outs of the Moralis NFT API to highlight the power and capabilities of this programming interface!
The Moralis NFT API supports more than three million NFT collections across multiple EVM-compatible blockchain networks. This includes everything from established projects like CryptoPunks, Pudgy Penguins, etc., to less-known collections that dropped just a couple of seconds ago.
With a single line of code, you can effortlessly get all NFT tokens owned by a user address, track NFT trades by marketplace, get ERC-721 on-chain metadata, and much more. And with this data, you can seamlessly build everything from a cryptocurrency wallet to an NFT marketplace!
So, if you want to build advanced Web3 projects, make sure to join Moralis today. You can create an account for free, and you’ll gain immediate access to the NFT API!
Summary: How to Get Verified NFT Collections
In today’s article, we kicked things off by covering the ins and outs of verified NFT collections. In doing so, we learned that they are collections that have been checked by an NFT marketplace like OpenSea, Rarible, or Blur. Next, we explained why you need an easy way to query this data, as it can help you filter out the noise when building Web3 projects.
From there, we demonstrated how to get all verified NFT collections of an address in three straightforward steps:
- Set Up Moralis
- Create a Script
- Run the Code
As such, if you have followed along this far, you can now get all verified NFT collections of an address in a heartbeat. From here, you can now incorporate this functionality into your next NFT marketplace, Web3 wallet, or portfolio tracker!
If you found this tutorial interesting, consider checking out more articles here on the Moralis Web3 blog. For instance, read our Polygon node guide or explore the ins and outs of account abstraction.
Also, if you’re serious about building Web3 projects, make sure to check out some additional tools Moralis offers. For instance, check out the amazing Streams API. With this tool, you can effortlessly set up Web3 webhooks to automatically get notified about relevant Web3 events!
If you want access to these industry-leading Web3 APIs, don’t forget to sign up with Moralis. You can create your account entirely for free and start leveraging the full power of blockchain technology today!
Read More: moralis.io