Tokenize Any Real Asset with ERC20 or NFT
Introduction
Asset tokenization is the way in which any real-world asset, tangible or intangible, has an associated digital file. In a broad sense, a token is basically a representation of something else, and in this case, each token represents a proportional part of the digitized asset.
According to the software functions implemented, we classify tokens into:
Fungible tokens: it is one that is issued in a certain amount (total supply), for example, Bitcoin will have a total supply of twenty-one million.
If today the price of BTC is 18 thousand USD, today each BTC represents 18 thousand USD.
If next week the price is 30 thousand USD, each BTC will represent 30 thousand USD.
Non-fungible tokens (NFT): Here each token represents an individual asset, for example, if I have three characters in a game, three different NFTs are issued:
What is blockchain technology?
Blockchain technology is as diverse as the mathematical functions of a self-executing program, which we developers call a smart contract.
We assign each smart contract model a name, consisting of three letters ERC (Ethereum Request for Comment) and a number to differentiate one model from another; if accepted, it becomes part of the standard technology. Thus, fungible tokens have the model called ERC20 and NFT tokens have the model ERC721.
What is an ERC20 token?
It is a set of instructions written in a smart contract deployed on the Ethereum blockchain and other compatible blockchains, which enables a variety of functions, including the builder function: which issues a full supply of coins or tokens:
Example 1. Digital money issuance:
An educational platform needs an ERC20 token for its students to make transactions:
We call the token "EUROedu Token".
Symbol "EUROedu".
The total supply is ten million units.
To simplify the example, we have set zero decimal places. With an initial value of one euro and credited to the account:
0x9E6deA275959beA36087280A55b11a54E366D8A2
Example 2. Issuance of bonds or financial debt instruments:
The oil company "Latam Oil Company" issues one million tokens representing one million bonds:
We call the token "BONUSlatam Token".
Symbol "BONUSlatam".
The total supply is one million units.
With an initial value of 50 USD and credited to account:
0x1FA2fC3e709AcD1D90c4cD9343d9f437CC9CfEf8
Example 3. Issuance of capitalization shares or financial instruments:
The automobile company BMW issues one hundred million "BMWshares" tokens representing 100 million shares:
We call the token "BMWshares Token".
Symbol "BMWshares".
The total offering is one hundred million units.
With an initial value of 80 USD and credited to account:
0x30D752489CF27652fcc2553AAaaB2D5DD9359C80
Note: In practice, ERC20 contracts are more complex, involving the deployment of a family of over a hundred small Smart Contracts (SC) for each project, each with mathematical functions to execute a specific action such as:
Control access to funds.
Transfer ownership of the SC.
Pause operations.
Sending or transferring a certain number of tokens to other accounts.
Burn or delete tokens.
Authorize or delegate token distribution.
Issue events such as sending tokens to other accounts.
Visualization in blockchain explorer
We will continue to explain example 3:
We deploy our contract on the Binance smart chain (BSC) and we can view it in the BSC explorer. With the contract address: 0x7764afFf48903d437d5581878aCdd0BBC518641C
In the address of the owners or issuers (red arrow): 0x30D752489CF27652fcc2553AAaaB2D5DD9359C80
We credited the hundred million BMWshares tokens (yellow arrow).
Distribution of the tokens
Now we register the Smart Contract (SC) in a cryptographic wallet, we will use the Metamask wallet:
We write the SC address in the Metamask wallet (red arrow): 0x7764afFf48903d437d5581878aCdd0BBC518641C
The name of the BMWshares (yellow arrow).
In the second image, the tokens are available to buyers of the tokenized shares.
What is an NFT?
An NFT is the technology that allows a digital object to be associated with a certificate of authenticity that guarantees official ownership to its sole owner. The creation of an NFT involves two steps:
Identify and store the image and descriptive information (metadata) of the NFT.
Connect the information stored in IPFS with the ERC721 smart contract.
A.-Identify and store the image and descriptive information (metadata) of the NFT.
A1.-Identify the image:
The following is the image of three examples of NFTs:
Example 1:
At the 2022 Ballon d'Or ceremony, Karim Benzema won two awards:
Brass and pyrite trophy NFT: Official 2D 2017 model
Example 2:
NFT of the official photo of the 2017 champion, of a South American soccer team:
Official champion photo 2017
NFT: Official 2D model 2017
Example 3:
The emerald hummingbird is a specimen of the tropical rainforests:
A2.-IPFS global storage:
The image and its corresponding information (metadata) of each NFT are stored by us in the Interplanetary File System (IPFS), formed by thousands of computers around the world, which guarantees that no person, entity, or government can alter the information.
This is a complex process, but we will explain it with the third example of the Emerald Hummingbird:
First, we upload the image and IPFS returns a link: ipfs/QmXXgGY2wbMBq1cFUV1Wp847b47bKpXtg7njap9DDgBt29
Then we upload the metadata of the emerald hummingbird, which is a file with the descriptive information of the NFT (what type of asset it is), in JSON form, the link in the image connects to this file (see red arrow):
IPFS returns a second link to this file:
ipfs/QmTroi95vbvhymTjYdaDjGNyy4DbEpnTnxrpm34r6XHHss
Now I use an application like pinata, as a gateway to view my IPFS files:
https://gateway.pinata.cloud/ipfs/QmTroi95vbvhymTjYdaDjGNyy4DbEpnTnxrpm34r6XHHss
B.- Connect the information stored in IPFS with the ERC721 smart contract.
Like ERC20 tokens, here is the constructor function:
We also have three other functions associated with the constructor function:
Name function.
Symbol function.
tokenUri function.
Next, we enter the data to display the contract:
Variable name = Hummingbird (See red arrow).
Variable symbol = EmeraldNFT (yellow arrow).
Variable tokenID = https://gateway.pinata.cloud/ipfs/QmTroi95vbvhymTjYdaDjGNyy4DbEpnTnxrpm34r6XHHss/ (Green arrow).
Visualization in blockchain explorer
We will continue to explain example three of the emerald hummingbird:
We deploy our contract on the Binance Smart Chain (BSC), and we can view it in the BSC explorer, with the SC address: 0xFB93A30Ec0555E82b71Dd62C679af8033A69b7DD
At the address of the owners or emitters (red arrow): 0x0245Ed33F7118BF6b373Ac84ba79Ff68F719E7fD
The address is accredited by EmeraldNFT (yellow arrow).
Distribution of NFTs
Now we register the Smart Contract (SC) in a crypto wallet, we will use the Metamask wallet:
We write the address of the SC in the Metamask wallet (red arrow). 0xFB93A30Ec0555E82b71Dd62C679af8033A69b7DD
The name of the NFT (yellow arrow).
In the second image, the EmeraldNFT is ready to ship to buyers.
Final remarks:
ERC20 tokens are useful for assets that are issued in a total amount and each token represents a portion of that total. All shares issued are equal therefore the tokens representing them are equal.
ERC721 tokens or NFTs are different from each other, when we have a group of NFTs that refer to an activity, we call it a collection of NFTs. Thus, all the NFTs in the CryptoKitties set form a collection.
As blockchain technology evolves every day, developers have designed smart contracts that create the concept of fractional NFTs, which combine NFTs and ERC20. So, we can represent a piece of real estate with an NFT, and the property belongs to two or more people through a certain amount of ERC20 tokens.