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
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.
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.
def name(tokenId)
Returns the name of the Crypto Item with id tokenId
- e.g. "My Crypto Item".
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).
def totalSupply(tokenId)
Returns the total number of Crypto Items with an id tokenId
.
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.
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.
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 amount
s, tokenId
s, 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.
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.
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.
def allowance(owner, spender, tokenId)
Returns the amount of Crypto Items with the id tokenId
which spender
is still allowed to withdraw from owner
.
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.
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.
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.
ApprovalEvent = RegisterAction("approval", "from", "to", "tokenId", "amount")
The event must be triggered on any successful calls to approve.
OEP-8 Python Template: Python Template