Token Standards - III

7D1t...morE
6 Jan 2024
133


This article is an article where I will explain ERC1155 and ERC777 standards in addition to ERC20 and ERC721 standards, which are token standards and which I mentioned in my two previous articles.




ERC115 Multi-Token Standard

This standard is a standardized version of the nft format used by Enjin in their gamefi project. This standard differs from the ERC721 NFT standard in that the circulating quantity of a tokenId value is not the same, making it easier for multiple accounts to own an NFT used in the game.




Below are the methods and structures of this standard.

event TransferSingle(operator, _from, to, id, value)

This is the event that should be triggered in a single transfer operation.

event TransferBatch(operator, from, to, ids[], values[])

Event that should be triggered during the transfer of multiple tokens and/or quantities.

event ApprovalForAll(owner, operator, approved)

event that should be triggered when the account given as operator is authorized or unauthorized to perform transactions on all token values of the account with the value owner.

event URI(value, id)

event that should be triggered when the previously set URI value for the token given as id is replaced with the value parameter.

function safeTransferFrom(from, to, id, value, data)

It is the method that transfers the amount of value from the Token given as id to the account address of the to parameter from the account given as from parameter.

function safeBatchTransferFrom(from, to, ids[], values[], data)

It is the method where the transfer operation is performed from the account address given as from to account address to the to account address, from the multiple Token values given as ids to the amounts in the values parameter.

function balanceOf(owner, id)

It is the method that returns how much ownership of the token with the given id value for the account given as owner.

function balanceOfBatch(owners[], ids[])

It is the method that returns the ownership of the accounts sent as owners in the token values in the given ids parameter.

function setApprovalForAll(operator, approved)

This is the method to give approval for the account given as operator for the account that calls this method or to remove the authorization given before.

function isApprovedForAll(owner, operator)

It is the method that returns the value of whether the account value given as owner parameter is authorized for the account sent in the operator parameter.

ERC1155TokenReceiver Interface Methods:

function onERC1155Received(operator, from, id, value, data)

This is the method that should be called after finishing all operations in safeTransferFrom method. This method returns the information whether the transfer operation has taken place or not.

function onERC1155BatchReceived(operator, from, ids, values, data)

This method should be called after finishing all operations in safeBatchTransferFrom method. This method returns the information about whether the multiple transfer operation has taken place or not.

ERC1155Metadata_URI Interface method

function uri(id)

Returns the URI of the Token value given as id.

ERC-1155 Metadata URI JSON Schema
Every project using the ERC1155 Multi-Token Standard must return JSON files with the following structure.For each id value, there must be a file in the "id.json" format.

{
    "title": "Token Metadata",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "description": "Identifies the asset to which this token represents"
        },
        "decimals": {
            "type": "integer",
            "description": "The number of decimal places that the token amount should display - e.g. 18, means to divide the token amount by 1000000000000000000 to get its user representation."
        },
        "description": {
            "type": "string",
            "description": "Describes the asset to which this token represents"
        },
        "image": {
            "type": "string",
            "description": "A URI pointing to a resource with mime type image/* representing the asset to which this token represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
        },
        "properties": {
            "type": "object",
            "description": "Arbitrary properties. Values may be strings, numbers, object or arrays."
        }
    }
}



ERC777 Token Standard


It is a standard built on top of the ERC20 standard. The purpose of this standard is to correct the situations encountered in the approve method.



The interface of this standard is as follows.


interface ERC777Token {
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function totalSupply() external view returns (uint256);
    function balanceOf(address holder) external view returns (uint256);
    function granularity() external view returns (uint256);

    function defaultOperators() external view returns (address[] memory);
    function isOperatorFor(
        address operator,
        address holder
    ) external view returns (bool);
    function authorizeOperator(address operator) external;
    function revokeOperator(address operator) external;

    function send(address to, uint256 amount, bytes calldata data) external;
    function operatorSend(
        address from,
        address to,
        uint256 amount,
        bytes calldata data,
        bytes calldata operatorData
    ) external;

    function burn(uint256 amount, bytes calldata data) external;
    function operatorBurn(
        address from,
        uint256 amount,
        bytes calldata data,
        bytes calldata operatorData
    ) external;

    event Sent(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256 amount,
        bytes data,
        bytes operatorData
    );
    event Minted(
        address indexed operator,
        address indexed to,
        uint256 amount,
        bytes data,
        bytes operatorData
    );
    event Burned(
        address indexed operator,
        address indexed from,
        uint256 amount,
        bytes data,
        bytes operatorData
    );
    event AuthorizedOperator(
        address indexed operator,
        address indexed holder
    );
    event RevokedOperator(address indexed operator, address indexed holder);
}



Source:

Get fast shipping, movies & more with Amazon Prime

Start free trial

Enjoy this blog? Subscribe to btcmillionaire

7 Comments