Non-Fungible Tokens on the Stellar Blockchain

Non-Fungible Tokens on the Stellar Blockchain

Blockchain solutions are democratizing currency creation. These “currencies” or “tokens” enable living economies around their associated product. In this economy, users are rewarded when they produce content or offer services on the product. For example, in the Filecoin ecosystem, users are rewarded Filecoin tokens when sharing personal disk space to store strangers’ files. These same users can in turn benefit from the services of the product by spending the tokens they have acquired. With our Filecoin example, users can spend the tokens they have accumulated to get extra storage space from strangers. If they never need extra storage space, they can trade their tokens for their market’s worth.

We can easily imagine a world where any physical asset is tokenized. A movie ticket at your local theater can be a token distributed by the cinema company. Once purchased you can use it at any time, exchange it, or give it to a friend. We have recently seen a surge of such products being announced.

How do we represent assets that aren’t identical?

While creating a fungible asset is great, most real world assets are non-fungible (meaning they are not identical in value and utility). For example, if a postal service wants to create its own tokens to represent stamps, they need the ability to dynamically create different tokens representing new types of stamps. Another example is real estate. How do you represent two different houses in the same token economy? We need a way to associate traits to individual tokens.

Solutions exist for blockchains with Turing complete smart contracts

The most common token formats is Ethereum ERC20. These tokens are by design non-fungible. But we are starting to see the emergence of a standard for non-fungible tokens: ERC721. For example, 0x, a protocol for decentralized token exchanges, has recently announced it is developing support for ERC721. Other projects are starting to be built on top of it too.

However here at OXIO we need fast and cheap transactions. Because blockchains such as Ethereum are subject to unpredictable transaction fees and varying confirmation times, it is hard for us to commit to them for production deployments.

Stellar however, is a blockchain that offers fast settlement for transactions with fixed low fees. Stellar enables users to very simply issue new tokens. A great guide to doing so can be seen here. But because Stellar does not have smart contract capabilities, and instead has a pre-built set of operations users can perform, we cannot transform these tokens into non-fungible tokens.

How do we make non-fungible tokens on Stellar?

Much like having a smart contract that keeps track of who owns what token, we can say that a Stellar issuer account holds the details of each token. This issuer account would create a completely new token for each asset representation (on the Stellar blockchain, a token definition is the combination of the issuer account and the asset code).

In other words, instead of creating 1,000 identical STAMP tokens, we create a token per stamp type. All users can see that the different tokens are tied to the same economy because they are issued by the same account AND we now have tokens that can represent different objects.

Using Manage Data as a description tool

Now that we have distinguishable tokens from the same source, how do we find out what they represent? To solve this, we can use the Manage Data operation. This operation manages a key/value store on the account that is readable by anyone. The token issuer account can therefore add an entry with the token code as the key for each new token created. The value is the token’s specific traits.

For example, if “Best Postal Service” wants to sell different stamps for local letters, international letters, local packages and international packages they would issue four tokens:

  • LOCLETTER with the manage data entry: LOCLETTER -> one local letter
  • INTLETTER with the manage data entry: INTLETTER -> one international letter
  • LOCPACKAGE with the manage data entry: LOCPACKAGE -> one local package
  • INTPACKAGE with the manage data entry: INTPACKAGE -> one international package

This way if Alice owns 2 LOCLETTER from Best Postal Service’s account she can always confirm in the data entry what that token represents. If Alice later wants to sell 1 LOCLETTER to Bob, Bob has all the tools to check the token definition on Best Postal Service’s account.

Conclusion

A few limitations to keep in mind:

  • The value part of a data entry is limited to 64 bytes so the issuer needs to be smart about descriptions (one possible solution is to use binary structures)
  • Stellar tokens are divisible up to seven decimal places. So you might want to distribute 0.0000001 LOCLETTER as one local letter

OXIO needs non-fungible tokens with fast and cheap transactions the way Stellar offers them. Stellar’s simple contracts have limitations that made us question if we could use it. This solution gives us the opportunity to keep exploring Stellar as a potential blockchain solution.


Categories: Engineering