ICON Token Standard
Jaechang Namgoong (@sink772)
A standard interface for tokens on ICON network.
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.
A token standard interface allows any tokens on ICON to be re-used by other third parties, from wallets to decentralized exchanges.
Returns the name of the token. e.g.
@external(readonly=True) def name(self) -> str:
Returns the symbol of the token. e.g.
@external(readonly=True) def symbol(self) -> str:
Returns the number of decimals the token uses. e.g.
@external(readonly=True) def decimals(self) -> int:
Returns the total token supply.
@external(readonly=True) def totalSupply(self) -> int:
Returns the account balance of another account with address
@external(readonly=True) def balanceOf(self, _owner: Address) -> int:
_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
_data can be attached to this token transaction.
_data can be empty.
@external def transfer(self, _to: Address, _value: int, _data: bytes=None):
Must trigger on any successful token transfers.
@eventlog(indexed=3) def Transfer(self, _from: Address, _to: Address, _value: int, _data: bytes): pass
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):
Copyright and related rights waived via CC0.