NFT Processing
Overview
In this section of our documentation we’ll provide readers with a better understanding of NFTs. This will teach the reader how to interact with NFTs, and how to accept NFTs via transactions sent on TON Blockchain.
The information provided below assumes the reader has already taken a deep dive into our previous section detailing Toncoin payment processing, while also assuming that they possess a basic understanding of how to interact with wallet smart contracts programmatically.
Understanding the Basics of NFTs
NFTs operating on TON Blockchain are represented by the TEP-62 and TEP-64 standards.
The Open Network (TON) Blockchain is designed with high performance in mind and includes a feature that makes use of automatic sharding based on contract addresses on TON (which are used to help provision specific NFT designs). In order to achieve optimal performance, individual NFTs must make use of their own smart contract. This enables the creation of NFT collections of any size (whether large or small in number), while also reducing development costs and performance issues. However, this approach also introduces new considerations for the development of NFT collections.
Because each NFT makes use of its own smart contract, it is not possible to obtain information about each individualized NFT within an NFT collection using a single contract. To retrieve information on an entire collection as a whole, as well as each individual NFT within a collection, it is necessary to query both the collection contract and each individual NFT contract individually. For the same reason, to track NFT transfers, it is necessary to track all transactions for each individualized NFT within a specific collection.
NFT Collections
NFT Collection is a contract that serves to index and store NFT content and should contain the following interfaces:
Get method get_collection_data
(int next_item_index, cell collection_content, slice owner_address) get_collection_data()
Retrieves general information about collection, which represented with the following:
next_item_index
- if the collection is ordered, this classification indicates the total number of NFTs in the collection, as well as the next index used for minting. For unordered collections, thenext_item_index
value is -1, meaning the collection uses unique mechanisms to keep track of NFTs (e.g., the hash of TON DNS domains).collection_content
- a cell that represents the collection content in TEP-64 compatible format.owner_address
- a slice that contains the collection owner's address (this value can also be empty).
Get method get_nft_address_by_index
(slice nft_address) get_nft_address_by_index(int index)
This method can be used to verify the authenticity of an NFT and confirm whether it truly belongs to a specific collection. It also enables users to retrieve the address of an NFT by providing its index in the collection. The method should return a slice containing the address of the NFT that corresponds to the provided index.
Get method get_nft_content
(cell full_content) get_nft_content(int index, cell individual_content)
Since the collection serves as a common data storage for NFTs, this method is necessary to complete the NFT content. To use this method, first, it’s necessary to obtain the NFT’s individual_content
by calling the corresponding get_nft_data()
method. After obtaining the individual_content
, it’s possible to call the get_nft_content()
method with the NFT index and the individual_content
cell. The method should return a TEP-64 cell containing the full content of the NFT.