How NFT works from the inside? We understand the stuffing

How NFT works from the inside? We understand the stuffing

Taking the first steps in the crypto space can be quite difficult. Previously, we talked about what is NFT, and now we will consider this concept from the technical side.
In this article, we will cover terms such as blockchain, smart contract, and Ethereum. And thus we will understand what is inside the non-fungible token and how NFT works. Now all this may seem too confusing. However, the concepts become very clear once you know exactly how they are applied in practice. Let’s explain on the fingers.
If you are buying NFTs, then most likely you are buying NFTs on Ethereum (ETH).
The exception is NBA Top Shots cards (FLOW blockchain) and several collections on the WAX ​​blockchain.
The bulk of the tokens sold on OpenSea and Rarible, as well as all the work on NiftyGateway and Foundation, are ETH tokens. So let’s talk about them for now.
Tokens live on blockchains. Let’s quickly brush up on what a blockchain is. And what about smart contracts?

What is the essence of blockchain?

Blockchain is a distributed (decentralized) ledger. Or a distributed database. That is, the data recorded in the blockchain is stored on many computers at the same time. And they therefore is not subject to any regulatory body. Data is stored in blocks. The data of the new blocks must not contradict the data of the previous ones, otherwise they will not be included in the chain.

What is blockchain?
What is blockchain?

Blockchains are resistant to hacking, manipulation attempts and provide reliable data storage due to distribution.
Blockchain can store different data.
The most popular blockchain is the Bitcoin blockchain. It stores only data about transactions with this cryptocurrency. And in general, any tokens works on the basis of the blockchain.

Ethereum and smart contracts – what is it?

But what if the computers serving the blockchain (nodes) will not only store data, but also execute the code?
Probably, Vitalik Buterin asked himself some such question before inventing Ethereum – the second most popular blockchain in the world. In Ethereum you can upload your program to the blockchain, and it will be executed on the nodes of the network. The community calls this program a smart contract. It is thanks to him that NFT works.
The ability to execute smart contracts is the main feature of Ethereum. And the cryptocurrency of the same name is not a value in itself. It is needs in order to provide settlements within the system. The best thing is that since our currency is also on the blockchain, smart contracts can track transfers themselves and make these transfers.

How NFT works the smart contract?

A smart contract can serve any task.
One of the most common tasks turned out to be servicing operations with some conventional units of value – tokens.
The token appears at the moment when the smart contract serving it appears.
That is, providing accounting for the ownership of tokens, the transfer and exchange of tokens, the use of tokens to perform any tasks.
A token is, at the very least, an ethereum token – in that sense it’s different from a physical coin or token that you have no matter what.
Your token is just an entry in the smart contract table.
This table records how many tokens belong to which ETH wallet.
Transferring tokens is simply executing a function in a smart contract that overwrites the data in the ownership table. Tokens works on exactly this principle.

Creating a token is adding a new entry to this table.

The token is inseparable from the smart contract. This is not some kind of unit that exists by itself, it exists only within the system that serves it.

What is NFT made of?

At this stage, we understand that your NFT is an entry in the smart contract table.

NFT in the smart contract
Your NFT is an entry in the smart contract table

Where is the picture then?
Here we got to the most interesting.

NFT = blockchain entry + metadata + media

We figured out about the record in the blockchain, but where is everything else?
In most of the existing NFTs, no one stores media and data about these media on the blockchain.
Storing large amounts of data on the Ethereum blockchain is very expensive. Even if you just want to store the name and, for example, the stat vector of your NFT sword on the blockchain, you will pay an additional 20-30 dollars at the time of release of this sword.. And every change in its characteristics (if you improve it, for example), you will also make it to the blockchain, which means you will pay for gas.
And storing large media is not only expensive, but also inconvenient.
Therefore, the blockchain usually stores only the address (URI) where information about the token (metadata) and media can be found.

cryptoart = Token + media

What are the risks of storing metadata off the blockchain? How will NFT works then?

Because of this situation, the token itself and the media are not related to each other.
The token is stored on the blockchain, while the metadata and media are stored somewhere else.
In the worst case, if the metadata and media are stored in a less secure place, it threatens to be inaccessible. Yes, you will have a token and it can still be of valueb, for example, to work as a pass to a certain club of owners. But no one can prove that this particular token was associated with a specific media.
Or the media will be changed. This can easily happen if the metadata and the media itself are served from the servers of the token creators.
In this case, you just have to trust the company or person who created or maintains this token. But even if we assume the crystal decency of these subjects, there are still force majeure. In general, we again face all the problems of centralized services – reliability, trust, and so on.
Of course, these problems are well known in the NFT community. And all major players are working in one way or another to maximize the decentralization of storage of the media part of non-fungible tokens.