Zetrix Documentation (EN)
  • Introduction
    • Overview of Zetrix
    • Why Build on Zetrix
  • GETTING STARTED
    • Quick Start Guide
    • Key Concept
  • ARCHITECTURE
    • Blockchain Layer
    • Consensus Mechanism
      • DPos
      • BFT
    • Node Type
    • Security
  • DEVELOPER RESOURCES
    • Smart Contract Development Toolkit
    • Smart Contract
      • Introduction
      • ZTP Standard
        • ZTP-20
        • ZTP-165
        • ZTP-721
        • ZTP-1155
      • Syntax
    • API
      • Overview
      • HTTP
      • Websocket
      • Keypair
    • SDK
      • Node.js
      • Go
      • Java
    • Interoperability
    • Testing and Auditing
      • Asset Issuance
      • Legal Evidence
      • Smart Contract Assets
    • Verifiable Credentials
      • Getting Started
      • API Reference
  • Node & Validator
    • Overview and System Requirements
    • Node Installation
      • Dedicated Address
      • Docker Deployment
    • Maintenance
    • Node Monitoring
    • Common Problems
  • GOVERNANCE
    • On-Chain Governance
    • Distribution of Interests
  • TOKENOMICS
    • Native Token
    • Staking and Rewards
    • Gas Fees and Transaction
  • ECOSYSTEM
    • DApps and Projects
    • Partnerships
    • Explorer and Analytics
  • Wallets
    • Supported Wallets
    • Wallet Intergration
  • Blockchain as a Service
    • BaaS
      • Zetrix Service
        • Core
        • Transaction
        • Contract
    • Zetrix Oraclize
    • Scheduler Contract
  • MISC
    • Burn Address
  • Troubleshooting & FAQ
    • Terminology
    • Security Best Practices
  • Community & Support
    • Developer Community
    • Official Support
    • Contributing to the Blockchain
Powered by GitBook
On this page
  • Simple Summary
  • Abstract
  • Motivation
  • Specification Token Methods
  • Zetrix Ecosystem Proposals
  1. DEVELOPER RESOURCES
  2. Smart Contract
  3. ZTP Standard

ZTP-721

Simple Summary

A standard interface for non-fungible tokens, also known as deeds.

Abstract

The following standard allows for the implementation of a standard API for NFTs (non-fungible tokens) within smart contracts. This standard provides basic functionality to track and transfer NFTs.

We considered use cases of NFTs being owned and transacted by individuals as well as consignment to third party brokers/wallets/auctioneers (“operators”). NFTs can represent ownership over digital or physical assets. We considered a diverse universe of assets, and we know you will dream up many more:

  • Physical property — houses, unique artwork

  • Virtual collectibles — unique pictures of kittens, collectible cards

  • “Negative value” assets — loans, burdens and other responsibilities

In general, all houses are distinct and no two kittens are alike. NFTs are distinguishable and you must track the ownership of each one separately.

Motivation

A standard interface allows wallet/broker/auction applications to work with any NFT on Zetrix. Additional applications are discussed below.

Specification Token Methods

balanceOf

Count all NFTs assigned to an owner , and returns the number of NFTs owned by owner , possibly zero.

self.balanceOf = function (paramObj) {
    Utils.assert(Utils.addressCheck(paramObj.owner), "ERC721: Invalid owner address: " + paramObj.owner);
    let balance = BasicOperationUtil.loadObj(BasicOperationUtil.getKey(BALANCES_PRE, paramObj.owner));
    if (balance === false) {
        return '0';
    }
    return balance;
};

ownerOf

Find the owner of an NFT, and returns the address of the owner of the NFT.

self.ownerOf = function (paramObj) {
    return _requiredOwned(paramObj.tokenId);
};

safeTransferFrom

Transfers the ownership of an NFT from one address to another address. This function SHOULD also enforce the onZTP721Received check to ensure that if the receiver is a contract address, it is able to receive NFTs.

self.safeTransferFrom = function (paramObj) {
    self.transferFrom(paramObj);
    /*
     if(paramObj.data !== "") {
         // Implement checkOnZTP721Received
     }
    */
};

transferFrom

Transfers the ownership of an NFT from one address to another address.

Note: THE CALLER IS RESPONSIBLE TO CONFIRM THAT THE RECEIVER IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST.

self.transferFrom = function (paramObj) {
    Utils.assert(Utils.addressCheck(paramObj.to), "ERC721: Invalid receiver address.");
    let previousOwner = self.p.update(paramObj.to, paramObj.tokenId, Chain.msg.sender);
    Utils.assert(previousOwner === paramObj.from, "ERC721: Incorrect owner");
};

approve

Change or reaffirm the approved address for an NFT.

self.approve = function (paramObj) {
    return self.p.approve(paramObj.to, paramObj.tokenId, Chain.msg.sender);
};

setApprovalForAll

Enable or disable approval for a third party ("operator") to manage all of Chain.msg.sender's assets.

self.setApprovalForAll = function (paramObj) {
    return self.p.setApprovalForAll(Chain.msg.sender, paramObj.operator, paramObj.approved);
};

getApproved

Get the approved address for a single NFT, and returns the approved address for this NFT.

self.getApproved = function (paramObj) {
    _requiredOwned(paramObj.tokenId);
    return self.p.getApproved(paramObj.tokenId);
};

isApprovedForAll

Query if an address is an authorized operator for another address, and returns true if operator is an approved operator for owner, false otherwise.

self.isApprovedForAll = function (paramObj) {
    return BasicOperationUtil.loadObj(BasicOperationUtil.getKey(OPERATOR_APPROVAL_PRE, paramObj.owner, paramObj.operator));
};

Note: A wallet/broker/auction application MUST implement the wallet interface (ZTP721Receiver interface with the onERC721Received function) if it will accept safe transfers.

PreviousZTP-165NextZTP-1155

Last updated 3 months ago

Sample ZTP721 contract can be found .

Zetrix Ecosystem Proposals
here