Non-Fungible Tokens
A non-fungible token (NFT) is a globally unique token representing ownership of any distinct asset. In Stardust, NFTs are implemented as a standalone output type called NFT Output. Once minted, the NFT Output gets assigned a unique NFT ID by the protocol based on the minting transaction. Issuers may choose to define immutable properties on the output upon minting, such as:
- The issuer identity, namely the address of the issuer.
- The metadata treated as binary data by the protocol.
NFTs as a Wallet
A distinct feature of L1 NFTs is the ability to function as standalone wallets. Each NFT owns an address derived from its
unique NFT ID, called NFT Address. NFT addresses look pretty much like regular Ed25519 addresses when encoded in bech32,
except they always start with
the character z
after the separator. (iota1z...
, smr1z...
).
Unlocking NFT-owned Funds
If NFT ID is a protocol generated value, how can funds locked under the NFT Address be unlocked in a transaction? The trick is to prove ownership of the NFT Output that defines NFT ID and hence NFT Address. To unlock an output locked to NFT Address, the owner has to include the NFT itself in the transaction. If the unlock of the NFT output is valid, it means that the owner authorized the transaction, therefore it may consume further outputs locked under that NFT Address.
Once minted, only the owner of the NFT Output may unlock it to include it in transactions. When an NFT Output is unlocked in a transaction but the output side doesn't contain it, the NFT gets burned. Any funds locked under its address are lost forever, since it is impossible to recreate the same output with the same NFT ID. Always check if the NFT owns something before burning it!
Supported Features
NFT Outputs support all possible (mutable) Features and Unlock Conditions, just like Basic Outputs. Therefore, you can define timelocks, expiration and storage deposit return conditions on NFTs, but also features like sender, metadata or tag. With such a powerful feature set, NFTs become first-class citizens in the ledger and also support smart contract chain interactions.
NFTs as native tokens?
The alert reader might be wondering: can't we just set the maximum supply of a native token to one to have a unique native token, therefore an NFT? The answer is yes, we could do that, but this approach has its limitations compared to the output based approach:
- NFTs link the actual owned asset via metadata to the token. Metadata of a native token sits in the foundry output, while the native token itself may reside in any other output. Therefore, the NFT and its metadata are detached from each other.
- The owner of the NFT as a native token has no control of the foundry, therefore it is impossible to melt the native token without the involvement of the issuer. The owner may still burn it, but then the storage deposit of the foundry can never be refunded.
- Native tokens can not own other asset in the ledger.