🎮 - NFTs

An NFT (“non-fungible token”) is a way to represent anything unique as an asset using - of course - a smart contract; it can only have one official owner at a time and no one can modify the record of ownership (except the owner by trading it) or create a new copy into existence.

The economic term “non-fungible” is something that you could use to describe something that has unique properties, such as your computer, your furniture and so on: things that are not interchangeable for other items. “Fungible” items, instead, can be exchanged because their value defines them, such as 1 dollar.

An NFT can only have one owner at a time: this ownership is managed by unique identifiers and metadata that no other token can replicate.

Entering the internet of assets

We are currently living in a world where everything is becoming more and more digital, therefore there’s a need to replicate the properties of physical items such as uniqueness, proof of ownership and scarcity.

NFTs give the ability to assign or claim ownership of any unique piece of digital data and use the Ethereum’s blockchain as a public ledger where you can verify this ownership. Using NFTs we could represent for example:

  • Digital art

  • Tickets for an event

  • Legal documents

  • Signatures

  • Collectible cards

  • Lots and lots more, just get creative!

Properties

Let’s see some of the NFT’s properties:

  • Each token has a unique identifier, directly linked to one address;

  • As we stated before, NFTs are not interchangeable with other tokens: each NFT is unique and the uniqueness is defined by its properties;

  • Each NFT owner and information is easy verifiable;

  • NFTs are scarce and their scarcity is defined by who creates them: for example, there could be 1000 tickets for a standing event or 1 token representing a Picasso piece of art.

NFTs in the gaming world

NFTs, of course, have seen a lot of interest from game developers: for example, if you really owned an in-game item, such as the Playerself cards, you can always sell them to make a profit when you’re done playing the game or just make a profit when you desire in order to buy a more powerful/rare item.

This also means that if the game is no longer maintained or played by the community, the items still remain yours. This unlocks a new level of gaming experience: all the items that you grind for can outlive the game itself, obtaining the memorabilia status and allow you to make a profit.

NFTs for developers

For smart contract developers, this special kind of token has its own proper standard: ERC-721 .

The term ERC (“Ethereum request for comment”) is used to address the technical documents used by smart contract developers at Ethereum; in our case, the ERC-721 (proposed by William Entriken, Dieter Shirley, Jacob Evans, Nastassia Sachs in January 2018) defines the rules required to implement an NFT.

ERC-721

This standard provides functionalities like to transfer tokens from one account to another, to get the current token balance of an account, to get the owner of a specific token and also the total supply of the token available on the network. Besides these it also has some other functionalities like to approve that an amount of token from an account can be moved by a third party account.

If a Smart Contract implements the following methods and events it can be called an ERC-721 Non-Fungible Token Contract.

Here you can find a list of methods and events that must be implemented in order to comply with the standard:

function balanceOf(address _owner) external view returns (uint256);
function ownerOf(uint256 _tokenId) external view returns (address);
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function approve(address _approved, uint256 _tokenId) external payable;
function setApprovalForAll(address _operator, bool _approved) external;
function getApproved(uint256 _tokenId) external view returns (address);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

But what if we wanted to have a single interface to manage multiple types of tokens (fungible and not fungible)? This is where the ERC-1155 standard comes to help.

ERC-1155

The idea is simple and seeks to create a smart contract interface that can represent and control any number of fungible and non-fungible token types. In this way, the ERC-1155 token can do the same functions as an ERC-20 (the standard for fungible tokens, more about it here) and ERC-721 token, and even both at the same time. And best of all, improving the functionality of both standards, making it more efficient, and correcting obvious implementation errors on the ERC-20 (the standard used for fungible tokens) and ERC-721 standards.

The main feature of this standard is that it allows the users to transfer multiple assets in a single function call or retrieve multiple balances in the same call, thus increasing the user-friendlyness of NFTs and thus reducing the fees paid by an address when performing these operations.

This is an example on how the transfer and balance functions change from a standard to another:

// ERC-721
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;

// ERC-1155
function safeBatchTransferFrom(
    address _from,
    address _to,
    uint256[] calldata _ids,
    uint256[] calldata _values,
    bytes calldata _data
) external;

// ERC-721
function balanceOf(address _owner) external view returns (uint256);

// ERC-1155
function balanceOfBatch(
    address[] calldata _owners,
    uint256[] calldata _ids
) external view returns (uint256[] memory);

Last updated