Guide: How to Develop Web3 DApps on Polygon zkEVM Network Using NFTScan NFT API

NFTScan
NFTScan
Published in
10 min readMar 29, 2024

--

Polygon zkEVM is a Layer 2 scalability solution for Ethereum built on zk Rollup. This solution uses ZK proofs to reduce transaction fees and increase throughput while maintaining the security of Ethereum L1. Specifically, the L2 layer executes transactions, completes complex computations, compresses and packages multiple transaction data, and creates a zero-knowledge proof result that is submitted to the mainnet (L1) for proof verification. Once the mainnet verifies the correctness of this proof, the data is stored on the mainnet, ensuring mainnet security.

According to NFTScan data as of March 29th, Polygon zkEVM Network has issued a total of 1,029,696 NFT assets, with 4,460 NFT Collections. There have been 1,882,116 interaction records generated, involving 487,945 wallet addresses. The total transaction volume is 5.09 ETH.

Polygon zkEVM NFTScan: https://zkevm.nftscan.com/

Create an NFTScan Developer Account

Before using the NFTScan API, you need to visit the developer’s website and create an account. Go to the NFTScan official website and click the “Sign Up” button for the NFTScan API to register.

https://developer.nftscan.com/user/signup

After logging in, find your unique API KEY on the Dashboard. Visit the API documentation and enter your API KEY in the appropriate location. Follow the instructions in the documentation to start using the API service. In the API documentation, developers can find various interface modes to choose from and select the most suitable one based on their needs.

NFTScan Developer Sign-up

In the Dashboard, developers can also view statistical data on their API usage, which helps track historical usage data. Additionally, NFTScan provides 1M CU of API call service to all registered developers for requesting all NFT API interfaces, and the CU never expires until it is used up!

After successfully registering a developer account and obtaining your API Key, you will need to access the NFTScan API documentation. The API documentation contains all available API endpoints and parameters, as well as detailed information on how to construct requests and handle responses. Please read the API documentation carefully and ensure that you understand how to use the API to retrieve the data you need. The NFTScan API service aims to help developers improve their experience in accessing NFT data analysis.

Currently, NFTScan has the largest and most comprehensive NFT Collection library across 24 blockchains including Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, OP Mainnet, Starknet, Scroll, Blast, Viction, Fantom, Mantle, Polygon zkEVM, Moonbeam, PlatON, Cronos, and Gnosis. It covers a wide range of NFT data, providing a complete set of interfaces to obtain ERC721 and ERC1155 assets, as well as transaction, project, and market statistics. It now supports over 60 public interfaces for EVM-compatible chains and a batch of similar model interfaces for Solana, Aptos, Bitcoin, and TON, greatly satisfying developers’ needs to index various types of NFT data.

Polygon zkEVM API Models

The Polygon zkEVM NFT API includes three main models, providing developers with detailed information and descriptions of the core fields within these models. This enables developers to retrieve data and utilize the information to serve their own Dapp services effectively.

Assets API: “Assets” represent the most crucial data fields within NFTs, uniquely identifying and describing digital assets. By extracting the “Assets” data from the Polygon zkEVM network, developers can gain comprehensive insights and build relevant applications. The “Assets” object provides the unique identification of digital assets, along with data about their entire lifecycle, laying the foundation for developers to understand and leverage NFTs.

Transactions API: The transactions model represents the complete history of all transactions related to an NFT asset on the blockchain, offering developers insights into the full lifecycle of NFT transactions. This includes minting, transfers, sales, and other transaction activities, allowing developers to gain an in-depth understanding of the flow and evolution of NFT assets within the Polygon zkEVM ecosystem. NFTScan continuously aggregates NFT transaction data from various blockchain networks, facilitating developers in tracking and understanding the dynamics of the NFT market. This data also assists developers in building NFT-based applications and tools.

Collections API: The Collections API provides NFTScan with off-chain data related to NFT collections, including descriptions, social media information, and other basic details. NFTScan retrieves this information through APIs provided by leading NFT markets across different blockchain networks. Additionally, the current floor price information is based on centralized data obtained through API from NFT market orders and is available for developers to access.

Polygon zkEVM NFT API Retrieval

1/Retrieve Assets Series

  • Get NFTs by account (Retrieve NFTs using a wallet address)
  • Get all NFTs by account (Retrieve all NFTs associated with a wallet address and group them by contract address. If the total number of NFTs owned by the account exceeds 2000, the returned NFTs will be limited to 2000 or less. In such cases, developers and users can use pagination queries to retrieve all NFTs owned by the account.)
  • Get minted NFTs by account (Retrieve NFTs minted by a specific wallet address)
  • Get NFTs by contract (Retrieve NFTs using a contract address, sorted by token_id in ascending order)
  • Get single NFT (Retrieve details of a single NFT)
  • Get multiple NFTs (Retrieve details of multiple NFTs from different contract addresses simultaneously)
  • Search NFTs (This interface returns a list of NFT assets by applying search filters in the request body. Assets are sorted by nftscan_id in ascending order.)
  • Get NFTs by attributes (This interface returns a set of NFTs belonging to contract addresses with specific attributes. NFTs are sorted by token_id in ascending order.)
  • Get all multi-chain NFTs by account (This interface returns all multi-chain NFTs owned by a specific wallet address, grouped by contract address.)

Here we can retrieve detailed information about one or multiple NFTs under an NFT Collection address using the “Get multiple NFTs” API “/v2/assets/batch”. The path parameters include “contract_address” and “token_id” for selection. In this case, we are querying the details of an NFT with token ID 1 under the contract address 0x9123c22f53adf7ce23e1fbb232ef444421516d39.

Clicking “Try it” will return the following data, including the basic information query of the NFT asset contract address, metadata information, rarity score, and ranking. Here, we can see that a total of 1 data is returned for our selected query.

2/ Retrieve Transactions Series

  • Get transactions by account (This interface returns a list of NFT transactions for a wallet address)
  • Get transactions by contract (This interface returns a list of NFT transactions for an NFT contract address
  • Get transactions by NFT (This interface returns a list of NFT transactions for a single NFT)
  • Search transactions (This interface returns a list of NFT transactions by applying search filters in the request body)
  • Get transactions by address (This interface returns a list of NFT transactions filtered by transaction parameters)
  • Get transactions by hash (This interface returns transaction records based on a list of transaction hashes)

Here we can retrieve the transaction history of a specific NFT item using the “Get transactions by NFT” API “/v2/transactions/{contract_address}/{token_id}”. The query parameters allow us to select the NFT event types for the transactions (Mint/Transfer/Sale/Burn), with multiple events separated by ‘;’.

Similarly, in this case, we are retrieving the transaction history of the NFT “PolygonZK City Girls” with token ID 1. We are querying specifically for Mint event types. The response data will contain all the key data of this NFT transaction, such as transaction hash, From and To addresses, block information, gas consumed, transaction timestamp, and other basic data that characterize the NFT transaction.

3/ Retrieve Collections series

  • Get an NFT collection (Retrieve details based on the contract address of the collection, including an overview and categorization of items based on their descriptions, distribution of owners, average price, floor price, and other basic information)
  • Search NFT collections (This endpoint returns a list of Collection information by applying search filters in the request body. Collections are sorted in ascending order based on deployment block number)
  • Get NFT collections by account (This endpoint returns a list of collections associated with a given account address, sorted by floor price from highest to lowest)
  • Get NFT collections by ranking (This endpoint returns a list of collections with a given ranking field, sorted based on the given sorting field and sorting direction)

Here we can retrieve the detailed information of an NFT collection using the “Get an NFT collection” API endpoint “/v2/collections/{contract_address}”. In this case, we are querying the details of the collection with the contract address 0x9123c22f53adf7ce23e1fbb232ef444421516d39 and the name “PolygonZK City Girls”.

4/ Collection Statistics: Statistical Analysis for Collection

  • Collection Statistics (This interface provides an analytical overview of NFT Collection statistics)
  • Collection Trade Distribution (This interface primarily provides the distribution of project trades)
  • Collection Trending Statistics (Mainly returns trading statistics ranking for a project)
  • Collection Holding Amount Distribution (This interface can provide information on the distribution of NFT project holdings)
  • Collection Holding Period Distribution (Data returns information about the distribution of NFT project holding periods)
  • Collection Blue Chip Statistics (Overview statistics for blue-chip projects)
  • Collection Blue Chip List (List of blue-chip projects associated with the project, referring to NFTScan Blue Chip Collection)
  • Collection Top Holder (Distribution of the top holders of the Collection)

Here we use the “Collection Statistics” API endpoint “/v2/statistics/collection/{contract_address}” to primarily retrieve an overview of analytical statistics for an NFT collection. This data can be compared to NFTScan Collections.

5/ Account Statistics Series

  • Account Overview Statistics (This interface returns an overview of statistical information for an account address, refer to NFTScan Overview)
  • Account Holding Distribution (This interface returns statistical information on the distribution of NFT holdings for an account address, refer to NFTScan Portfolio)
  • Account Holding NFT Trending (This interface returns statistical information on the trending NFT holdings or quantities for an account address, refer to NFTScan Portfolio)

6/ Analytic Statistics Series

This series of APIs is commonly used to retrieve data analysis and statistics-related information on the NFTScan Polygon zkEVM network, such as Trade Ranking and Mint Amount. Such APIs allow developers or users to query, analyze, and retrieve statistical data related to specific data sets or indicators and can be used for various purposes, including market analysis, trend tracking, investment decision-making, and understanding the nature of specific data.

https://zkevm.nftscan.com/

7/ Refresh Metadata

  • Refresh NFT metadata
  • Refresh NFT metadata by contract

Interfaces like Refresh Metadata can assist developers or users in submitting backend tasks to refresh metadata. Once reviewed, these tasks will refresh the specified item or the entire contract metadata.

8/ Other

  • Get the latest block number (Returns the latest block number reached by NFTScan)
  • Get NFT amount by account (Returns information on the quantity of ERC721 and ERC1155 NFTs owned by the account address specified in the request body)
  • Get NFT owners by contract (Returns a list of owners for the specified ERC721 NFT contract address, with NFTs sorted by token_id)
  • Get owners by an NFT (Returns a list of owners for the specified ERC1155 NFT, with NFTs sorted by account_address)

Building Relevant NFT API Requests

Creating NFT data requests with NFTScan is incredibly simple and convenient for developers. They can easily find the required API in the documentation and review details like the interface address, request method, and parameters. They can then choose a programming language, such as JavaScript, Python, Java, etc., and utilize the corresponding HTTP request library to send a well-constructed request to the API endpoint, including all necessary headers and parameters. This entire process is quick and hassle-free, allowing developers to seamlessly implement their requests based on the documentation instructions.

For example, if we want to request the detailed information of 0x9123c22f53adf7ce23e1fbb232ef444421516d39, using the API“/v2/collections/{contract_address}” and making an HTTP GET request to the NFTScan API endpoint, we can construct the request in Python using the requests library in the following way:

import requests

# API endpoint
url = "https://api.nftscan.com/v2/collections/0x9123c22f53adf7ce23e1fbb232ef444421516d39"

# Send a GET request
response = requests.get(url)

# Check the response status code
if response.status_code == 200:
# Get the response content in JSON format
data = response.json()

# Filter necessary headers and parameters from the response
# This is just an example; you need to filter based on the specific response data in the API documentation
necessary_headers = response.headers
necessary_parameters = data # Assuming the required parameters are in the JSON data of the response

# Output necessary headers and parameters
print("Necessary headers:", necessary_headers)
print("Necessary parameters:", necessary_parameters)
else:
print("Request failed, status code:", response.status_code)

In this example, we use the Python requests library to send an HTTP GET request to the NFTScan API and then extract the necessary headers and parameters from the response. It is important to note that the specific extraction operations should be determined based on the returned content outlined in the API documentation.

NFTScan is the world’s largest NFT data infrastructure, including a professional NFT explorer and NFT developer platform, supporting the complete amount of NFT data for 24 blockchains including Ethereum, Solana, BNBChain, Arbitrum, Optimism, and other major networks, providing NFT API for developers on various blockchains.

Official Links:

NFTScan: https://nftscan.com

Developer: https://developer.nftscan.com

Twitter: https://twitter.com/nftscan_com

Discord: https://discord.gg/nftscan

Join the NFTScan Connect Program

--

--