Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (76 sloc) 3.24 KB
iip title author discussions-to status type category created
2
ICON Token Standard
Jaechang Namgoong (@sink772)
Final
Standards Track
IRC
2018-08-07

Simple Summary

A standard interface for tokens on ICON network.

Abstract

This draft IRC describes a token standard interface to provide basic functionality to transfer tokens. We adopted the token fallback mechanism inspired by ERC223, that a token contract can implement to prevent accidental transfers of tokens to contracts and make token transactions behave like other ICX transactions.

Motivation

A token standard interface allows any tokens on ICON to be re-used by other third parties, from wallets to decentralized exchanges.

Specification

Methods

name

Returns the name of the token. e.g. MySampleToken.

@external(readonly=True)
def name(self) -> str:

symbol

Returns the symbol of the token. e.g. MST.

@external(readonly=True)
def symbol(self) -> str:

decimals

Returns the number of decimals the token uses. e.g. 18.

@external(readonly=True)
def decimals(self) -> int:

totalSupply

Returns the total token supply.

@external(readonly=True)
def totalSupply(self) -> int:

balanceOf

Returns the account balance of another account with address _owner.

@external(readonly=True)
def balanceOf(self, _owner: Address) -> int:

transfer

Transfers _value amount of tokens to address _to, and MUST fire the Transfer event. This function SHOULD throw if the self.msg.sender account balance does not have enough tokens to spend. If _to is a contract, this function MUST invoke the function tokenFallback(Address, int, bytes) in _to. If the tokenFallback function is not implemented in _to (receiver contract), then the transaction must fail and the transfer of tokens should not occur. If _to is an externally owned address, then the transaction must be sent without trying to execute tokenFallback in _to. _data can be attached to this token transaction. _data can be empty.

@external
def transfer(self, _to: Address, _value: int, _data: bytes=None):

Eventlogs

Transfer

Must trigger on any successful token transfers.

@eventlog(indexed=3)
def Transfer(self, _from: Address, _to: Address, _value: int, _data: bytes):
    pass

Token Fallback

A function for handling token transfers, which is called from the token contract, when a token holder sends tokens. _from is the address of the sender of the token, _value is the amount of incoming tokens, and _data is arbitrary attached data. It works by analogy with the fallback function of the normal transactions and returns nothing.

@external
def tokenFallback(self, _from: Address, _value: int, _data: bytes):

Implementation

References

Copyright

Copyright and related rights waived via CC0.

You can’t perform that action at this time.