DEV Community

Cover image for Guide: How to Develop Web3 DApps on Mantle Network Using NFTScan NFT API
NFT Research
NFT Research

Posted on

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

Mantle Network is a Layer 2 scaling solution built on top of the Ethereum blockchain, utilizing Optimistic rollup technology. Incubated by BitDAO, it aims to provide a faster and more cost-effective transaction experience than Ethereum. As Mantle’s underlying chain is built on the OP Stack and is compatible with EVM, developers can easily migrate their existing Ethereum network developer tools and APIs, reducing development costs.

According to NFTScan data as of February 21st, Mantle Network has issued a total of 3,251,118 NFT assets, with 21,920 NFT collections. There have been 4,952,270 interaction records, involving 1,179,502 wallet addresses, and a total transaction volume of 1,889,464.81 MNT.

Mantle NFTScan: https://mantle.nftscan.com/

Image description

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.

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.

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!

Review the Mantle API Documentation

After successfully registering a developer account and obtaining an API Key, you need to review the NFTScan API documentation. The API documentation contains all the available API endpoints and parameters, as well as detailed information on how to construct requests and handle responses. 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 is designed to help developers improve their experience of obtaining NFT data analysis.

NFTScan currently has the largest and most comprehensive NFT Collection library in the entire network. It supports full data of NFTs from Ethereum, Solana, BNBChain, Bitcoin, TON, Polygon, zkSync, Aptos, Linea, Base, Avalanche, Arbitrum, OP Mainnet, Starknet, Scroll, Viction, Fantom, Moonbeam, PlatON, Cronos, and Gnosis. It covers a wide range of NFT data and provides a set of interfaces to obtain ERC721 and ERC1155 assets, transactions, projects, market statistics, and more. It now supports over 60 public interfaces for EVM-compatible chains, as well as a set of interfaces for Solana, Aptos, Bitcoin, and TON with the same model, which largely meets the needs of developers to index various types of NFT data.

Mantle NFT API Models

The Mantle 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 Mantle 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 Mantle 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.

Image description

Mantle 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 retrieve detailed information about NFTs under a contract address using the “Get NFTs by contract” interface:

“/v2/assets/{contract_address}”

The path parameter includes “contract_address” as a selection, and in this case, we are querying the MantleNFT project.

Image description

Clicking on “Try it,” the data response shows the basic data and metadata information for all items in the NFT Collection. In this case, we have selected MantleNFT, which has a total of 38,638 items. The returned data is sorted based on token_id, and for example, we have an item with id 0:

  1. Basic data for a single item: 0x7cf4ac414c94e03ecb2a7d6ea8f79087453caef0, named MantleNFT, with an NFT Token id of 0. It represents 1% of the project. It follows the erc721 protocol. The wallet address of the owner when minted, the timestamp/hash address of the mint, and the Token URI address are also included. Other data such as the latest trade price, symbol, and timestamp are also available.

  2. Metadata: The metadata for this project is hosted on IPFS and is in the format of image/png. It includes the storage path and detailed descriptions of the image’s features.

  3. Rarity Description: It has a rarity score of 1.1785878980631936, ranking it at 7137 for overall rarity.

Image description

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 using the “/v2/transactions/{contract_address}/{token_id}” endpoint. The query parameters allow us to choose the event types for the NFT transactions (Mint/Transfer/Sale/Burn), separated by ‘;’.

In this case, we are retrieving the transaction history for MantleNFT Item 0. We include all event types (Mint/Transfer/Sale/Burn) in the query, and the response will contain all the key transaction data related to this NFT item. This includes transaction hashes, From and To addresses, block information, gas consumption, and transaction timestamps, among other basic data that characterize the NFT transactions. The data returned shows that there is currently only one mint-related transaction record for this item.

Image description

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)

In this case, we will choose the endpoint “Get NFT collections by account”.“/v2/collections/own/{account_address}” We will retrieve all the NFT collections with the erc721 protocol that are owned by the wallet address: 0xc279cce107a9272ffec07cb1b7471491c2fee5a2. A total of 20 items will be returned.

Image description

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 choose the Collection Statistics API:“/v2/statistics/collection/{contract_address}” to retrieve the top holder details and distribution data for a contract address with the name MantleNFT. Please visit: https://mantle.nftscan.com/0x7cf4ac414c94e03ecb2a7d6ea8f79087453caef0

Image description

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 Mantle 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://mantle.nftscan.com/

Image description

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

Developers can find the required Fantom API interface and parameters in the NFTScan API documentation. They can then use their chosen programming language, such as Python, Java, JavaScript, etc., to write the API request code.

Here, we will use the Market Cap Ranking API: “/v2/statistics/ranking/marketcap” to retrieve the market cap ranking data for NFT collections on the Mantle network. We will make an HTTP GET request to NFTScan’s API interface, and use the Python requests library to construct the request as follows:
`

import requests

NFTScan API Endpoint for Market Cap Ranking

api_url = "https://api.nftscan.io/v2/statistics/ranking/marketcap"

Build a GET request, add request parameters as needed

response = requests.get(api_url)

Check if the request was successful

if response.status_code == 200:
# Get the returned JSON data
data = response.json()

# Process the data here, you can print, analyze, or perform other operations
print(data)
Enter fullscreen mode Exit fullscreen mode

else:
# Print the error message
print(f"Error: {response.status_code}, {response.text}")
`

Image description

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 20 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[](url)

Top comments (0)