iip | title | author | discussions-to | status | type | category | created |
---|---|---|---|---|---|---|---|
3 |
ICON Non-Fungible Token Standard |
Jaechang Namgoong (@sink772) |
Final |
Standards Track |
IRC |
2018-08-27 |
A standard interface for non-fungible tokens on ICON network.
This draft IRC describes non-fungible tokens (NFTs) standard interface to provide basic functionality to track and transfer NFTs. NFTs can represent ownership over digital or physical assets, which can be owned and transferred by individuals as well as consignment to third party operators.
A standard interface allows wallet/broker/auction applications to work with any NFT on ICON network.
This standard is inspired by the ERC721 token standard. Unlike IRC2 token standard, where we adopted the token fallback mechanism, we preserved the approve/transferFrom methods in this NFTs standard, because there can not be multiple withdrawals with NFTs as in ERC20 (see ERC20 API: An Attack Vector on Approve/TransferFrom Methods).
Returns the name of the token. e.g. CryptoBears
.
@external(readonly=True)
def name(self) -> str:
Returns the symbol of the token. e.g. CBT
.
@external(readonly=True)
def symbol(self) -> str:
Returns the number of NFTs owned by _owner
. NFTs assigned to the zero address are considered invalid, so this function SHOULD throw for queries about the zero address.
@external(readonly=True)
def balanceOf(self, _owner: Address) -> int:
Returns the owner of an NFT. Throws if _tokenId
is not a valid NFT.
@external(readonly=True)
def ownerOf(self, _tokenId: int) -> Address:
Returns the approved address for a single NFT. If there is none, returns the zero address. Throws if _tokenId
is not a valid NFT.
@external(readonly=True)
def getApproved(self, _tokenId: int) -> Address:
Allows _to
to change the ownership of _tokenId
from your account. The zero address indicates there is no approved address. Throws unless self.msg.sender
is the current NFT owner.
@external
def approve(self, _to: Address, _tokenId: int):
Transfers the ownership of your NFT to another address, and MUST fire the Transfer
event. Throws unless self.msg.sender
is the current owner. Throws if _to
is the zero address. Throws if _tokenId
is not a valid NFT.
@external
def transfer(self, _to: Address, _tokenId: int):
Transfers the ownership of an NFT from one address to another address, and MUST fire the Transfer
event. Throws unless self.msg.sender
is the current owner or the approved address for the NFT. Throws if _from
is not the current owner. Throws if _to
is the zero address. Throws if _tokenId
is not a valid NFT.
@external
def transferFrom(self, _from: Address, _to: Address, _tokenId: int):
Must trigger on any successful token transfers.
@eventlog(indexed=3)
def Transfer(self, _from: Address, _to: Address, _tokenId: int):
pass
Must trigger on any successful call to approve(Address,int)
.
@eventlog(indexed=3)
def Approval(self, _owner: Address, _approved: Address, _tokenId: int):
pass
Copyright and related rights waived via CC0.