HRC-721 NON-FUNGIBLE TOKEN(NFT)

Introduce

What are non-fungible tokens?

Non-Fungible Tokens (NFTs) are used to uniquely identify someone or something. This type of token can be perfectly used as a platform for selling: collectibles, keys, lottery tickets, concert seat numbers, sports games, etc. This type of token has incredible potential, so it needs a proper standard. HRC-721 is here to solve this problem!

What is HRC-721?

HRC-721 introduces a standard for NFTs, in other words, tokens of this type that are unique and may have a different value from another token from the same smart contract, perhaps because of its age, rarity, or even The look and feel of it. Wait a minute, how does it look?

Yes. All NFTs have a uint256 variable called tokenId, so for any HRC-721 contract, the pair of values contract address, tokenId must be globally unique. That is, a dapp could have a "transformer" that takes a tokenId as input and outputs an image of some cool thing, like a zombie, a weapon, a skill, or an amazing kitty!

Text

HRC-721 is a non-fungible token standard that implements token APIs in smart contracts.

It provides functions such as transferring tokens from one account to another, getting the current token balance of an account, getting the owner of a token, and the total token supply available across the network. Besides that, it also has other functions, such as approving a certain amount of tokens in the account to be transferred by third-party accounts.

If a smart contract implements the following methods and events, it can be called a HRC-721 non-fungible token contract. Once deployed, it will be responsible for tracking tokens created on Hash Ahead.

Method

    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

Example

Let's see how important a standard is that allows us to simply check any HRC-721 token contract on Hash Ahead. We only need the Application Binary Interface (ABI) of the contract to create an interface to any HRC-721 token. Below we will use a simplified API to make the example simpler.

First, make sure you have the Web3.py Python library installed:

Web3.py example

Besides the standard events, the CryptoKitties contract has some other interesting events.

Let's look at two of them, Pregnant and Birth.

Last updated