Our previous token solution aims at fungible tokens. We invent another solution to cope with non-fungible ones. They can represent unique and non-divisible assets, such as real estate and collectibles.
Overview
Similar to fungible tokens, inside each UTXO, there are two parts associated with a non-fungible token in the data part of the token contract:
- A public key: to control issuance or transfer of a token
- An integer: to uniquely identify a token.
Again, the token in a UTXO is transferred by signing using the private key corresponding to the public key. The difference is that each UTXO only stores one unique token, instead of multiple exchangeable/fungible tokens.
Issue Tokens
One special token UTXO containing the issuer can be split into multiple UTXOs to issue new tokens. Below is an example of splitting into two and thus issuing a new token i to Alice.
The relevant code is listed below with self-explanatory comments inline.
Transfer Tokens
A token in a UTXO can be transferred as follows.
The relevant code is listed below.
Combination
The following diagram shows the operation of a non-fungible token.
Here is the complete contract code and an example to use it.
Discussion
We have only shown the basics of non-fungible tokenization. It is straightforward to extend it, e.g.,:
- Issue multiple new tokens at once in one transaction
- Transfer multiple tokens in a single transaction
- Place a cap on total supply
- Burn tokens