Recent Artilces

BLOG

Token Contract

← All Topics

token.iost


Description

Token contract is used for token creation, distribution, transfer and destruction, can freeze token for some time, and also with support for configuring the full name of tokens, decimal places, transfer attributes

Info

contract_idtoken.iost
languagenative
version1.0.3

API

create(tokenSym, issuer, totalSupply, config)

Create token.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol, unique within the contract. Its length should be between 2 and 16 and could only contain characters in [a-z0-9_]
issuerstringtoken issuer who has token issue permission. Calling this interface requires this account’s “token” permission
totalSupplynumberTotal amount of supply
configjsontoken configuration. It contains 4 keys: 
fullName —— string type, full name of the token.
canTransfer —— bool type, whether the token can be transferred.
decimal —— number type, the token decimal.
onlyIssuerCanTransfer —— bool type, whether the token is allowed to transfer only by token issuer.

issue(tokenSym, to, amount)

Issue tokens.

Calling this interface requires token issuer's "token" permission.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
tostringThe account who receives token
amountstringThe amount could be both integer and decimal, such as “100”, “1.22”

transfer(tokenSym, from, to, amount, memo)

Token transfer.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
fromstringAccount who sends token, Calling this interface requires this account’s “transfer” permission
tostringAccount who receives token
amountstringThe amount of token transferred
memostringAdditional information

transferFreeze(tokenSym, from, to, amount, ftime, memo)

Transfer and freeze tokens.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
fromstringAccount who sends token, Calling this interface requires this account’s “transfer” permission
tostringAccount who receives token
amountstringThe amount of token transferred
memostringAdditional information

destroy(tokenSym, from, amount)

Destroy tokens.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
fromstringAccount who destroys token, Calling this interface requires this account’s “transfer” permission
amountstringThe amount of token destroyed

balanceOf(tokenSym, from)

Get the token balance.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
fromstringAccount name which is queried
Return valueTypeRemark
balancestringaccount balance

supply(tokenSym)

Get the token circulation, that is, the total amount of tokens that have been issued and have not been destroyed.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
Return valueType
supplystring

totalSupply(tokenSym)

Get the total circulation of tokens.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
Return valueType
Total supplystring

token721.iost


Description

Token721 contract is used for the creation, distribution, transfer and destruction of non-fungible tokens.

Info

contract_idtoken721.iost
languagenative
version1.0.0

API

create(tokenSym, issuer, totalSupply)

Create tokens.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol, unique within the contract. Its length should be between 2 and 16 and could only contain characters in [a-z0-9_]
issuerstringtoken issuer who has token issue permission. Calling this interface requires this account’s “token” permission
totalSupplynumberTotal amount of supply

issue(tokenSym, to, metaData)

Issue tokens.

Calling this interface requires token issuer's "token" permission.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
tostringThe account who receives token
metaDatastringMeta data for token
Return valueTypeRemark
tokenIDstringTokenID is the token identification. In a certain token, the system will generate a specific tokenID for each token issued which won’t be duplicated in a certain kind token.

transfer(tokenSym, from, to, tokenID)

Token transfer.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
fromstringAccount who sends token, Calling this interface requires this account’s “transfer” permission
tostringAccount who receives token
tokenIDstringToken ID

balanceOf(tokenSym, from)

Get the token balance.

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
fromstringaccount name
Return valueTypeRemark
balancenumberAccount balance

ownerOf(tokenSym, tokenID)

Get the owner of a particular token

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
tokenIDstringToken ID
Return valueTypeRemark
accountstringOwner account name

tokenOfOwnerByIndex(tokenSym, owner, index)

Get the index token owned by the account

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
ownerstringAccount name
indexnumberToken index, integer
Return valueType
tokenIDstring

tokenMetadata(tokenSym, tokenID)

Get the meta data of the token

Parameter NameParameter TypeRemark
tokenSymstringToken symbol
tokenIDstringToken ID
Return valueType
metaDatastring
Last Updated On August 01, 2019
Vote For Us
Vote for IOST Watch and receive Daily IOST reward