Compressed NFT processing
Introduction
Compressed NFT (cNFT) is a specialized digital asset format that optimizes data storage. Data compression algorithms reduce file sizes while preserving each asset’s uniqueness. This process saves server space and lowers data storage and transmission costs. In addition, Merkle trees minimize storage requirements and enhance the efficiency of cNFT collections.
Features
- Resource savings: Merkle trees store only essential data, reducing gas costs and network load.
- Improved scalability: Efficient contracts can handle large NFT volumes without performance loss.
- Optimized data storage: Keeping minimal on-chain information boosts system responsiveness and saves space.
- Enhanced security: Merkle trees enable fast data integrity checks and robust asset protection.
- Cost reduction: Shift minting costs to end users and create “virtual” on-chain items only when needed.
Supporting compressed NFT in wallets and marketplaces
Current limitations
Most popular wallets and marketplaces do not display unclaimed cNFTs or NFTs from collections that are not official partners. For example, the Telegram wallet and the Getgems marketplace index only the first 200 items for unofficial collections, which poses challenges for larger collections.
Attack scenario
A malicious actor could create hundreds of thousands of NFTs at minimal cost, forcing marketplaces to store all related data—even if the attacker does not host the items but generates them on demand.
Potential solution
Provide a dedicated interface where users can claim their cNFTs. Once claimed, NFTs are indexed and displayed in wallets and marketplaces as standard NFTs, ensuring better visibility and accessibility.
Configuration and deployment guide
NFT collection and item preparation
Before deployment, you need to prepare the metadata and images for your NFTs.
Metadata preparation
-
Collection metadata
Create acollection.json
file that includes the required fields as specified in the NFT token data standard.
Example:{
"name": "<collection name>",
"description": "<collection description>",
"image": "<link to the image (e.g. https://yourdomain.com/logo.png)>"
}
-
NFT item metadata
For each NFT, create a separate JSON file (e.g.,0.json
,1.json
, etc.) with the required fields as specified in the NFT token data standard.
Example:{
"name": "<item name>",
"description": "<item description>",
"image": "<link to the image (e.g. https://yourdomain.com/0.png)>"
}
Resource preparation
- Images: Prepare images for the collection (for example,
logo.png
for the avatar) and for each NFT (for example,0.png
,1.png
, etc.). - JSON files: Host your
collection.json
and NFT JSON files on a publicly accessible server or repository. Ensure each file has a unique URL.
Note: All images and JSON files must be directly accessible via their URLs.
TON Connect manifest preparation
Create a TON Connect manifest JSON file to describe your application during the wallet connection process.
Example:
{
"url": "<app url>",
"name": "<app name>",
"iconUrl": "<app icon url>"
}
Note: Ensure that this file is publicly accessible via its URL.
Owner list preparation
Prepare an owners.txt
file that lists the addresses of NFT owners, one per line. The first address corresponds to item index 0
, the second to item index 1
, and so on.
Example:
UQDYzZmfsrGzhObKJUw4gzdeIxEai3jAFbiGKGwxvxHinf4K
UQCDrgGaI6gWK-qlyw69xWZosurGxrpRgIgSkVsgahUtxZR0
Infrastructure preparation
Set up a server to host your API and the interface for claiming NFTs. Also, obtain a domain for accessing the API. In this example, a local test deployment is run on a home machine using ngrok to create a public URL.
Claiming API and interface setup
-
Clone the repository
Clone the project containing all necessary source files:git clone https://github.com/nessshon/cnft-toolbox
-
Install dependencies
Install Docker, Docker Compose, and ngrok, and ensure they are properly configured on your machine. -
Create a Telegram bot
Create a Telegram bot and obtain its API token. -
Expose your API
Use ngrok to create a public URL for testing:ngrok http 8080