Skip to content

Latest commit

 

History

History
174 lines (124 loc) · 5.67 KB

OEP-8.mediawiki

File metadata and controls

174 lines (124 loc) · 5.67 KB

  OEP: 8
  Title: Crypto Item Standard
  Author: tanyuan <tanyuan666@gmail.com>, zhoupw <zhoupw@gmail.com>, tonyclarking<tonyclarking@gmail.com>, blckchan<1258176714@qq.com>
  Type: Standard
  Status: Accepted
  Created: 2018-10-16

Table of Contents

Abstract

The OEP-8 Proposal is a standard interface for Crypto Items. This standard allows you to transfer any amount of tokens for different Crypto Items from one address to another address. It combines the advantages of OEP-4 and OEP-5 to make transferring different types of Crypto Items convenient.

Motivation

With the development of smart contracts and dApps, the requirement of transferring different amounts of different tokens has become more intense. If you want to transfer different amounts of different tokens from one address to another address or to do batch transfers, it is very difficult. The OEP-8 Proposal aims to solve this problem.

Specification

Methods

name

def name(tokenId)

Returns the name of the Crypto Item with id tokenId - e.g. "My Crypto Item".

symbol

def symbol(tokenId)

Returns a short string symbol of the Crypto Item with id tokenId - e.g. "MCI". This 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

def totalSupply(tokenId)

Returns the total number of Crypto Items with an id tokenId.

balanceOf

def balanceOf(address, tokenId)

Returns the number of Crypto Items with the id tokenId assigned to address. The parameter address must be a 20-byte address. If not, this method must throw an exception.

transfer

def transfer(from, to, tokenId, amount)

Transfers amount of Crypto Items with the id tokenId from the from address to the to address. The parameters from and to must be 20-byte addresses. If not, this method must throw an exception.

transferMulti

def TransferMulti(args)

state = {
  from: <FROM ADDRESS>,
  to: <TO ADDRESS>,
  tokenId: <TOKEN ID>,
  amount: <AMOUNT>
}

The transferMulti method allows to transfer multiple times with varying amounts, tokenIds, from addresses and to addresses. The parameters from and to must be 20-byte addresses. If not, this method must throw an exception. If any of the transfers fail, all of the transfers must be failed, and the method must throw an exception.

approve

def approve(from, to, tokenId, amount)

The approve method allows to grant the amount of Crypto Items with the id tokenId from the from address to the to address. If this function is called again it overwrites the amount allowed for the to address. The parameters from and to must be 20-byte addresses. If not, this method must throw an exception.

transferFrom

def transferFrom(spender, from, to, tokenId, amount)

The transferFrom method is used for a withdraw workflow - allowing the spender address to withdraw amount of Crypto Items with the id tokenId from the from address and send it to the to address. The parameters spender, from and to must be 20-byte addresses. If not, this method must throw an exception.

allowance

def allowance(owner, spender, tokenId)

Returns the amount of Crypto Items with the id tokenId which spender is still allowed to withdraw from owner.

approveMulti

def approveMulti(args)

state = {
  from: <FROM ADDRESS>,
  to: <TO ADDRESS>,
  tokenId: <TOKEN ID>,
  amount: <AMOUNT>
}

The approveMulti method allows to grant multiple amount of Crypto Items with the id tokenId. The parameters from and to must be 20-byte addresses. If not, this method must throw an exception.

transferFromMulti

def transferFromMulti(args)

state = {
  spender: <SPENDER ADDRESS>,
  from: <FROM ADDRESS>,
  to: <TO ADDRESS>,
  tokenId: <TOKEN ID>,
  amount: <AMOUNT>
}

The transferFromMulti method is used for a withdraw workflow - allowing multiple calls to transferFrom. The parameters spender, from and to must be 20-byte addresses. If not, this method must throw an exception.

Event

transfer

TransferEvent = RegisterAction("transfer", "from", "to", "tokenId", "amount")

The event must be triggered when tokens are transferred, including zero value transfers. A token contract which creates new tokens must trigger a transfer event with the from address set to null when tokens are created. A token contract which burns tokens must trigger a transfer event with the to address set to null when tokens are burned.

approval

ApprovalEvent = RegisterAction("approval", "from", "to", "tokenId", "amount")

The event must be triggered on any successful calls to approve.

Implementation

OEP-8 Python Template: Python Template