Stellar provides an environment to trade any assets with fast and virtually-free transactions. Coupled with the ability to issue capped and non-fractional units of an asset, these properties make Stellar an ideal blockchain for issuing Non-Fungible Tokens (NFTs).
Many creators and NFT artists have now discovered the benefits of creating and trading NFTs on Stellar. The Litemint NFT marketplace on Stellar provides a stats page showing monthly NFT sales volume, top sales, unique items, creators.
There are different ways to create NFTs on Stellar, and even more ways to store and address large amounts of data for these NFTs. This guide is about how to use Stellar to create NFTs that can stand the test of time while maximizing interoperability with the Stellar ecosystem services and wallets.
💡 NOTE The best practices described below have been developed and used to issue thousands of future-proof NFTs for artists on the Litemint marketplace. These NFTs are compatible with all Stellar wallets and are traded on the Stellar Decentralized Exchange (SDEX).
💡 NOTE #2 Back in Meridian 2021, the Stellar Development Foundation hosted its first-ever docsprint, including an NFT competition to design the very first #StellarDev NFT badge.
Use decentralized storage
As an NFT issuer, you should think carefully about how to store your NFT metadata. Using decentralized storage is a strong requirement for future-proofing your NFTs.
❌ Storing the data on-chain can be very costly and is not currently scalable on Stellar. Although it can be viable for some use cases (e.g. storing small images — NFTs from StellarQuest have successfully used this approach), it is not recommended for general use cases.
✔️ Follow the guidelines developed by Protocol Labs for storing data on the InterPlanetary File System (IPFS) and addressing NFT data with Multiformats Content Identifier (CID) specification. The IPFS protocol is broadly used in the NFT industry and its adoption is fast growing with IPFS-based decentralized storage services like web3.storage and nft.storage.
💡 PRO TIP There are several free services for IPFS, you can create an account with web3.storage, they currently offer 1TB of IPFS storage for free.
💡 PRO TIP You can find more details on the ipfs.io website including advanced instructions to upload data to IPFS with filenames preservation.
Create a metadata file
NFTs can represent ownership for anything. A metadata file is a must to provide extra information about your NFTs, for example: description, image, video, audio, name, title, terms, circular reference to the on-chain asset can be specified with metadata.
Battle-tested and practical standards have been specified for creating metadata files on Ethereum with ERC-721 tokens. Follow these standards for creating your metadata files for Stellar NFTs.
Here is an example of a JSON metadata file for an NFT on Stellar, with the image field containing the canonical form of link to NFT data on IPFS:
{
"name":"Stellar Punk 0100",
"description":"just came back from the Moon.. it's a temple to our Sun… hand drawn xlm network moon punks are here! always 1/1 animated edition",
"image":"ipfs://QmZM3EYeamVihFFVd5kZmG35ua19DcKT4gNh4aofaPQ2H6",
"code":"sPUNK",
"issuer":"GC64XYMQAF43THY3DSGYW7X4TA322HP3XHOQKA4FAI2736HDADTHVF2O",
}
💡 PRO TIP Technically, ERC-721 makes all fields optional by allowing empty values. Thus, you are practically free to use any field name to best describe your NFTs. Issuers can optionally publish a JSON schema to help clients validate the NFT metadata file structure (document contract).
Link your asset to metadata
ipfshash is a common naming convention by contracts on Ethereum or APIs (e.g. Pinata) to refer to the data CID. Use it for naming the data entry on your NFT issuer account. Learn how to use ManageData to set data entries on Stellar accounts.
💡 PRO TIP Litemint looks up the ipfshash data entry against the NFT issuer account to discover images, video, audio, full descriptions, and other properties so that your assets can seamlessly benefit from using the same naming convention.
Setup a TOML file
Setting up a TOML file provides immediate interoperability with all services and wallets on the Stellar ecosystem. It is highly recommended that all assets you issue on Stellar, NFTs or not, follow the SEP-0001 protocol standard to provide a valid stellar.toml file.
Another incentive behind setting up a stellar.toml file for your NFTs is that, because it is trivial and costless to issue assets on Stellar, most Stellar ecosystem services and wallets tend to discard TOML-less assets and/or flag them as spam. Ensure you maximize interoperability with as many services as possible on Stellar.
Here is an example stellar.toml file for an NFT:
[DOCUMENTATION]
ORG_URL="<https://ink.litemint.store>"
[[CURRENCIES]]
code="sPUNK"
issuer="GAKZGD5BFXZ7P7P45WHTM6DODMOEWWJUSCAIPGYIVIPYQSVR6MM6YR7M"
display_decimals=7
name="Stellar Punk 0100"
desc="just came back from the Moon.. it's a temple to our Sun… hand drawn xlm network moon punks are here! always 1/1 animated edition"
image="<https://ipfs1.litemint.com/ipfs/QmW7TqAccf6U5Yfs7gwHgNtkqPTE4M4zELHMfhkhTdZAxb>"
fixed_number=1
💡 PRO TIP It is a good idea to not directly link your image to the default ipfs.io gateway in your TOML, as the gateway is slow and rate limited.
💡 PRO TIP Provide an optimized version of the art if needed to allow fast-loading from services and wallets on Stellar.
You should also configure your issuing account’s homeDomain field via setOptions to reference your TOML file’s domain so that others know where to look.
Use the stroop
In order to implement non-fractional assets, it is necessary to use the smallest, indivisible amount available to send, receive, and trade assets on Stellar as units. The smallest amount for an asset issued on Stellar is called a stroop, which is equal to one ten-millionth or 0.0000001 of a Stellar lumen (XLM). Therefore, to issue one NFT, you would issue 0.0000001 of an XLM on Stellar.
💡 PRO TIP Such small amounts may cause issues on the Stellar DEX because Core internally uses INT32 for the fractional representation of prices, and the INT32 type can only store values between -2,147,483,648 to 2,147,483,647 (inclusive). There are solutions to bypass these limitations, one of which is described in this blog entry by Litemint.
🔒 Freeze your NFT account!
Put simply, without immutability, assets on Stellar are not NFTs. Freezing the NFT issuer account is key to provide immutability for the above setup:
- It prevents accounts from issuing additional units of the token.
- It prevents data entries from being modified.
- It prevents the merge operation allowing for accounts to be recreated.
- It prevents revocation of ownership (the Authorization Immutable flag could also be used, but alone, it would not prevent the other points above).
By default (i.e. without multisig setup), to freeze an account, you would set its master key weight to zero. In order to do so, you can use the setOptions operation.
🚨 Since freezing is an irreversible process, make sure that you only freeze your NFT account and not your wallet.
💡 PRO TIP To prevent any issues with existing user accounts, the Litemint Create Tool generates new random accounts on-the-fly during the NFT minting process. These accounts are funded and frozen at once in a single transaction (5 operations), so there is no risk for users (besides losing the 1.5 XLM reserve and fees). Here is an example of such a transaction.
💡 PRO TIP Some use cases may require the option to unfreeze an account at a future date. This can be done on Stellar via a pre-auth transaction with setOptions masterWeight=1 along with timebound constraints and by setting the hash of that transaction as signer against the account prior to freezing it.
— — -
And there you have it! You’ve successfully minted an NFT on Stellar. If you want to learn more about minting an NFT through Litemint, our FAQs will help you get started.
Want to continue the conversation and find other like-minded folks building on Stellar? Join the community on the Stellar Dev Discord and tune in on Thursday, February 24th 10am EST for the next Stellar Shop Talk session on NFTs!
Best Practices for Creating NFTs on Stellar was originally published in Stellar Community on Medium, where people are continuing the conversation by highlighting and responding to this story.