ZTP-20
Simple Summary
A standard interface for tokens.
Abstract
The following standard allows for the implementation of a standard API for tokens within smart contracts. This standard provides basic functionality to transfer tokens, as well as allow tokens to be approved so they can be spent by another on-chain third party.
Motivation
A standard interface allows any tokens on Zetrix to be re-used by other applications: from wallets to decentralized exchanges.
Specification Token Methods
name
Returns the name of the token - e.g. "MyToken"
OPTIONAL - This method can be used to improve usability, but interfaces and other contracts MUST NOT expect these values to be present.
symbol
Returns the symbol of the token. E.g. “MYTKN”
OPTIONAL - This method can be used to improve usability, but interfaces and other contracts MUST NOT expect these values to be present.
decimals
Returns the number of decimals the token uses - e.g. 6
, means to divide the token amount by 1000000
to get its user representation.
totalSupply
Returns the total token supply.
balanceOf
Returns the account balance of another account with address account
.
transfer
Transfers value
amount of tokens to address to
. The function SHOULD throw an exception if the message caller’s account balance does not have enough tokens to spend.
transferFrom
Transfers value
amount of tokens from address from
to address to
.
The transferFrom
method is used for a withdraw workflow, allowing contracts to transfer tokens on your behalf. This can be used for example to allow a contract to transfer tokens on your behalf and/or to charge fees in sub-currencies. The function SHOULD throw an exception unless the from
account has deliberately authorized the sender of the message.
approve
Allows spender
to withdraw from your account multiple times, up to the value
amount. If this function is called again it overwrites the current allowance with value
.
allowance
Returns the amount which spender
is still allowed to withdraw from owner
.
Last updated