Understanding and Creating non-fungible tokens on Algorand blockchain

Undoubtedly, Algorand has emerged as one of the leading blockchain projects enabling developers to build decentralised finance applications. With the vision to powering a cross-border economy, the robust layer-1 architecture makes it easy to deploy smart contracts (stateless & stateful), create and manage Algorand standard assets, perform atomic transfers and rekey account keys to keep their wallets cold while spending from it. The Algorand Standard Assets feature forms the core and bases for creating cryptocurrencies on the Algorand network. Algorand equally allows dapps to create their crypto assets for different transaction purposes. Dapps can create different asset types depending on the use case. Broadly, the Algorand network supports both fungible and non-fungible tokens.

Fungible tokens are non-unique assets that are created and are traded or used for payments among users. They have monetary value within the ecosystems. Fungible tokens remain the most dominant use case of standard assets. Examples of fungible tokens are cryptocurrencies, stable coins, loyalty points and in-app credits/points. On the other hand, and equally important though given little attention, are non-fungible tokens (NFTs), which are equally standard assets are created on the Algorand blockchain network. NFTs are unique assets created on the Algorand blockchain, which are not mutually interchangeable or split into multiple denominations or units. For example, in real estate, land titles and property ownership are unique to each property as NFT. With a fair idea of NFTs, it is important to understand the intricacies in creating and managing NFTs on the Algorand chain. First, you will need to configure the properties of each non-fungible asset that you intend to create. Some of the properties to consider at the initial stages are highlighted in this article.

Asset name property:

The asset name is a string character and symbolizes the complete name of the asset that you will create on the blockchain. This is the name that users will see on the chain and will serve as the reference point for your token by users. The asset name may contain spaces and or symbols. For example, if you can choose any of the following as your asset names: MaryEstate or Mary Estate or Mary1Estate. Remember, however, that the asset name has a limit of 32 bytes.

Asset unitname

The unitname property is a string variable, which represents a shorter form of the asset name property discuss above. It is an abbreviation or short form of the long asset name that is coined for easy recognition. For instance, BTC and ETH tokens stand for Bitcoin and Ethereum, respectively. Similarly, when creating an Algorand asset, the unitname property represents the short form of the asset name. an asset created with the name MaryEstate, the unitname property can be coined as MET. A holder of this non-fungible asset scan as well say I hold a MET token, which represents an estate property such as a house or land called MryEstate. Note also that this property has a byte limit of 8.

Asset Decimals

Non-fungible assets are unique and non-divisible and this will inform how many decimals offset you will set in your non-fungible ASA. The decimal property functions differently for fungible and non-fungible assets. The ALGO token is a fungible token which is divisible by up to 0.0001. In creating such an asset, which is divisible up to 0.0001 you would set  4 as the asset decimal property value. According to the Algorand developer help docs, asset creation takes the following options:

  • If set to 0, the asset is not divisible beyond its base unit.
  • If set to 1, the base asset unit is tenths.
  • If 2, the base asset unit is hundredths, and so on.

Non-fungible assets take the property flag of 0 since they are not divisible and so the property definition will be –decimal 0. Remember, however, that for any asset decimal flag, the maximum you can set is 19, i.e.  decimal 19

Asset total supply [--total]

Asset total supply refers to the maximum number of tokens that were created for this asset. The total token supply implies the entire available units of this token created for the smart contract account. For example, the total supply of Algos is 10 billion Algos and that includes all the tokens that exist in all accounts on the Algorand network. Before understanding how to set this value for non-fungible tokens, it is important to first understand how this value is calculated on Algorand. The total supply [--total property] for Algorand is set taking into consideration the:


1. The decimal flag as explained above
2. The total token supply.

Example: if you are creating an asset with a total supply of 6000 and 2 decimal places, the –total value will be defined as
S*10^D,  where S is the total supply and D is the decimal places.

The --total property for 6000 token supply will be =6000*10^2

--total = 600000. This value then translates to 6000.00 total tokens

However, in your smart contract, you will assign 600000 as the total token supply value and 2 decimals. Algorand will recognise this and set your total token supply to 6000. It is possible to own 20.23 or 35.05 of this asset.

However, the process for non-fungible tokens is different. Non-fungible tokens are unique and are not divisible. Therefore, the decimal for non-fungible tokens will be 0. In creating an NFT of 500 total supply, the --total variable property is determined as follows.

Put the values in the formula --total = 500*10^D, = 500*10^0 = 500

Therefore, only 500 NFTs will be issued on the chain and accounts can only own whole number tokens such as 10, 14, 20 with no decimals.

The asseturl property

The --asseturl property is a string with a 32 bytes size limit. It allows developers to set a webpage where users can read more about the asset that is created. If you have a block page, whitepaper or wiki page, this is the right place to set it. With the MaryEsate asset, the --asseturl is set as below

--asseturl "https://Maryholdings.org/resources/MareEstate

Asset Creator

As the name implies, this property takes the Algorand public address that is creating the asset. This is an immutable flag that is set and cannot be changed. See the example below

 --creator <your_account_address> and will translate to real-life example of
--creator <EGT5EN5H4SN53SVVVY5ZDIK5P5ZLXMLPWX3FBUW5OHTSHJNEOULCURV5TI>

At this stage, all the properties needed for creating the non-fungible asset are set. Next is to initiate the asset creation transaction using the details below. You will initial a goal command to execute the transaction

Input command

$ ./goal asset create --asseturl " https://Maryholdings.org/resources/MareEstate " --creator < EGT5EN5H4SN53SVVVY5ZDIK5P5ZLXMLPWX3FBUW5OHTSHJNEOULCURV5TI > --decimals 0 --name "MaryEstate" --note "Total supply will never change!" --total 1 --unitname MET --datadir <name_of_node_data_directory> --wallet <name_of_node_wallet>


Output

The above command output a unique Asset ID on the Algorand chain, which will forever be the reference for the asset. You can use the Asset ID to search on the various Algorand block explorers for transactions and other details about the non-fungible tokens created.

Conclusion

Once the asset has been created, there are other configuration management steps you can take to manage the asset usage. Regarding the uniqueness and indivisibility of the non-fungible tokens created, a user can only be assigned 1 unit of this asset. For instance, you can have 2 MET non-fungible tokens, but you cannot have 2.5 or 3. 2 MET tokens that were created above. Just think of it that you own either your land certificate or not you cannot own 1.5 of the land certificates where it is created as a non-fungible token.