Jun 017 min read

Semi-Fungible Tokens: The Real World is Messy!

A new standard (SIP-013) for Semi Fungible Tokens has been accepted.

Source: Clarity Innovation Lab, Clarity Standards

The recent surge in popularity of NFTs and the growth of NFT marketplaces on the Stacks Network (NFTs on Bitcoin) is demonstrating the potential for these emerging technologies. Although this activity is currently more or less limited to ‘digital collectibles’ these innovations point the way to more general applications. Collectibles are just one type of a much bigger and more general category. NFTs can actually represent any kind of unique digital or physical asset from a digital collectible to a piece of music or from a car to a driving license.

Fungible assets, on the other hand, are used to represent interchangeable, non-unique things. Money for example but also shares in a company or even the individual H2O molecules in a glass of water. If two people swap the same number of fungible tokens then there is a sense in which nothing has actually changed - whereas if we swap my Hockney for your Kandinsky or my Ferrari for your 2CV then there is a strong sense of a change!

In the context of blockchains both of these types of unique and interchangeable digital assets can be transferred and bought and sold between users via decentralised code known as Smart Contracts. But as separate concepts, by themselves, fungible and non-fungible tokens don’t actually take us too deep into the cracks and crevices where things in the the real world reside.

The Real World is Messy

If only the real world could be described by just these two simple concepts. Non-unique and unique things seem to reside at opposite ends of a spectrum. But if we step back and rephrase them as say ‘things’ and ‘quantities of things’ we can start to see how powerful the idea really is. It turns out that mixing these two concepts, into what has become known as Semi Fungible Tokens (SFTs), opens the door for smart contracts to describe many more real world scenarios and thereby offer solutions for many new problems.

The SFT concept originated with the Enjin team on Ethereum in the context of gaming where they provide a natural description for the types of things one finds in an online game. For example, imagine a simple game scenario with varying quantities of the following 5 things;

Describing this arrangement with either FT’s or NFTs would be really tricky and this is the problem that SFTs were invented to solve. SFTs provide a natural description for mixing unique and non-unique things together in the same standard - in this case the thing and the quantity of the thing.

The problem can also be understood by thinking about what an NFT essentially is. In one way of thinking an NFT is simply a mapping (within a smart contract) between an address and a unique id (called the token id)

address :——> token id

The elegance of the SFT can then be expressed as a generalisation of this mapping;

(address, token id) :---> int (quantity) 

In the above example the Rhinestone is unique and can be owned by one address - so the combination of its owner address and its token id map to the quantity 1. The ownership of golden goblets can be split over at most 200 addresses owning one each (maximal distribution) or at the other end to one address owning all 200 (minimal distribution) - or any distribution in between.

The real power of the idea kicks in when one realises the number of places - beyond gaming - where this arrangement occurs.

  • Tickets - e.g. different types of tickets within the same event as the unique element and the number of each type issued as the quantities - or alternatively the events themselves as the thing and the total number of all classes of ticket per event as the quantity

  • Coupons - the number of coupons per item

  • Editions of artwork - the artwork as the NFT and the number of editions as the quantity

  • In fashion - the individual garments and the quantities of each garment - or a single garment with different sizes or colours and the quantity of each

  • In other fields this concept could be used to model say the molecules in a mixture and the number of moles of each molecule as the quantities

In this way SFTs open the door for a huge range of applications.

SFTs on Stacks

Over recent weeks Marvin Janssen of the Clarity Lab has been working with leading developers within the Stacks Community to develop a new standard for SFTs - the proposal is currently a Pull Request and the supporting work can be found in Github. Standards, known as Stacks Improvement Proposals (SIPs) allow developers to agree on ways of working which allow them to build products, services and tools inter-operably - providing more secure and robust solutions to end users. The great news is that the proposal has now been tentatively approved by the Steering Committee. An activation process is being agreed for SIP-013 and this is a now green flag to the developer community to get behind this standard and build interesting applications.

Clarity and SFT Post Conditions

Clarity is the Smart Contract programming language for the Stacks Blockchain. The advantages of Clarity over other smart contract languages are well documented elsewhere but it is worth restating the main benefits for end users here;

  • Clarity is Interpreted - it is not a compiled language and so the contract code can be read directly from the blockchain - this makes it more secure, readable and transparent

  • Clarity is Turing incomplete - meaning the execution cost can be calculated precisely in advance - this makes it more secure, less complex and less expensive to run than other smart contract languages

  • Clarity supports Post Conditions - clauses that end users can add to their transactions, to guard against fraud and bugs by adding constraints to the operation of the smart contract.

The SIP-013 standard has been designed with a great deal of thought for how the Post Conditions can work to protect end users. The examples of the standard include implementations which use a burn and mint mechanism in the transfer function. That is when quantities of a thing (NFT) are transferred from one owner to another the end user (or UI) can include constraints or limits on the movement of the assets. If a Clarity Contract tries to exceed these limits - e.g. by trying to steal all the NFTs in the end users wallet then the transaction will fail leaving everything unchanged.

What’s the Connection with Bitcoin?

The Stacks Blockchain operates independently but reconciles on Bitcoin. This means the asset you purchase and own on Stacks benefit from the highest level of security available - a great foundation for solving the new class of interesting problems which SFTs address.

Example SFT Marketplace - Thirteen-Market

A decentralised SFT marketplace has been provided by the Clarity Innovation Lab as an example for using SIP-013 and SFTs in the real world. The marketplace also includes the use of Generalised Fungibles in minting, listing and buying of items from the marketplace.

The SIP-013 traits and annotated contracts for this example can be found on testnet;

Share this story