OEPs icon indicating copy to clipboard operation
OEPs copied to clipboard

OEP: ONT ID based non-fungible token

Open AlverLyu opened this issue 6 years ago • 0 comments

Title: ONT ID based non-fungible token Status: draft Author: [email protected] Created: Nov. 9th, 2018


Abstraction

This proposal defines the interfaces for ID based non-fungible tokens (INFTs), which is similar to OEP-5 except that it uses ONT ID as the address, instead of the one derived from the public key.

Motivation

Traditional tokens use the address derived from public key. Signatures generated with the private key are required when transferring tokens. In this approach, tokens are irrelative with ONT ID, which means many dApps need to maintain two types of accounts: identities and token addresses. Moreover, if losing the private key, the tokens in the corresponding address are loss as well. From this view, this proposal involves the ID based address for NFTs.

Specification

INFT is unique, and has a unique token ID. Each INFT has an owner, which is an ONT ID. When transferring an INFT to another ONT ID, one SHOULD include a signature in the transaction which could pass the verification with one of the public keys binded to current owner’s ID. Meanwhile the identifier of the verification key SHOULD be specified, which is an integer allocated by the ONT ID contract when binding the key.

Basic Methods

name

public static string name()

Returns the name of the INFTs - e.g. "My ID Tokens".

symbol

public static string symbol()

Returns a short string symbol of the token - e.g. "MIDT". The symbol SHOULD be short (3-8 characters is recommended), with no whitespace characters or new-lines and SHOULD be limited to the uppercase latin alphabet (i.e. the 26 letters used in English).

totalSupply

public static BigInteger totalSupply()

Returns the total number of INFTs.

balanceOf

public static BigInteger balanceOf(byte[] id)

Returns the number of INFTs assigned to the specific ID. If id is not a valid ONT ID, this method SHOULD throw an exception.

Ownership Methods

ownerOf

public static byte[] ownerOf(byte[] tokenId)

Returns the ID currently marked as the owner of tokenId. If the tokenId can not query an owner ID, this method SHOULD throw an exception.

transfer

public static bool transfer(byte[] to, byte[] tokenId, byte[] keyId)

Transfers an INFTs of tokens from the owner to the to account. to SHOULD be an valid ONT ID. If not, this method SHOULD throw an exception. keyId SHOULD be the identifier of the verification key binded to the owner’s ONT ID. If the key is not available, this method SHOULD throw an exception.

transferMulti

public static bool TransferMulti(object[] args)

public struct State
{
     public byte[] to;
     public byte[] tokenId;
     public byte[] keyId;
}

The transferMulti allows transfer multiple INFTs from multiple owners to multiple to multiple times. The parameter is an object array, and the object is a State struct. to is the receiver, and SHOULD be ONT IDs. keyId SHOULD be the identifier of the verification key binded to the owner’s ONT ID. If the key is not available, this method SHOULD throw an exception. If any of the sub-transfers fail, all the transfers SHOULD be cancelled, and the method SHOULD throw an exception.

approve

public static bool approve(byte[] to, byte[] tokeId, byte[] keyId)

The approve allows to grant an INFT to to account multiple times. If this function is called again it overwrites to or tokenId. to SHOULD be an ONT ID. If not, this method SHOULD throw an exception. keyId SHOULD be the identifier of the verification key binded to the owner’s ONT ID. If the key is not available, this method SHOULD throw an exception.

takeOwnership

public static bool takeOwnership(byte[] to, byte[] tokenId)

Assigns the ownership of the INFT with ID tokenId to to, which SHOULD be an ONT ID. If not, this method SHOULD throw an exception.

Events

transfer

public static event transfer(byte[] from, byte[] to, byte[] tokenId)

MUST trigger when tokens are transferred, including zero value transfers. A token contract which creates new NFTs MUST trigger a transfer event with the from account set to null. A token contract which burns tokens MUST trigger a transfer event with the to account set to null when tokens are burned.

approval

public static event approval(byte[] from, byte[] to, byte[] tokenId)

MUST trigger on any successful call to approve.

AlverLyu avatar Nov 09 '18 02:11 AlverLyu