# Token (Asset)
Token is a digital asset on the blockchain. A token can be used:
- as a cryptocurrency to pay for goods and services within a project, as well as for crowdfunding;
- as an object or resource in games etc.
A token can represent a physical or an intangible object.
The words “token” and “asset” are used interchangeably in the Waves ecosystem.
WAVES is the native token on the Waves blockchain; more about it in the WAVES article.
All other tokens are custom tokens issued on behalf of some account. Any account that has enough WAVES to pay a fee can issue its own token. The new token is immediately available:
- for transfers between accounts,
- for trading on the WX Network exchange developed by the third-party team from the community (except for NFTs; smart assets trading is temporarily unavailable),
- for payments attached to dApp script invocation.
# Custom Token Parameters
Custom token example: https://wavesexplorer.com/assets/HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS.
Below is an example of JSON representation returned by the GET /assets/details/{assetId}
method of Node REST API:
{
"assetId": "HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS",
"issueHeight": 2868644,
"issueTimestamp": 1637666412469,
"issuer": "3PEpe1vvqGKo6gTAfyGPxdgNcfECGAZTaqy",
"issuerPublicKey": "9YMFU94AX1BhZX6xQU4Y5yR4e78MCUQzB8EZapjuS9WM",
"name": "Puzzle",
"description": "DeFi 2.0 is here.",
"decimals": 8,
"reissuable": false,
"quantity": 46965909720523,
"scripted": false,
"minSponsoredAssetFee": 100000,
"originTransactionId": "HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS",
"sequenceInBlock": 1
}
Field | Description |
---|---|
assetId | Token ID: base58 encoded byte array. The token ID is calculated as a hash of the token parameters upon issue. See also the Token ID article |
issueHeight | Blockchain height (the sequence number of the block) at which the token is issued |
issueTimestamp | Token issue timestamp: Unix time in milliseconds |
issuer | Address of issuer account: base58 encoded byte array |
issuerPublicKey | Public key of issuer account: base58 encoded byte array |
name | Token name. From 4 to 16 bytes (1 character can take up to 4 bytes) |
description | Token description. From 0 to 1000 bytes |
decimals | Number of decimal places, from 0 to 8 |
reissuable | Reissue availability flag |
quantity | Total supply of token on the blockchain specified in atomic units. From 1 to 9,223,372,036,854,775,807. Total supply can change as a result of reissue or burning, see Token Operations below |
scripted | There being a script: true for smart asset, false for regular token. More about smart assets |
minSponsoredAssetFee | For sponsored asset only: an amount of asset that is equivalent to 0.001 WAVES More about sponsorship |
originTransactionId | ID of the transaction that issued the token: base58 encoded byte array |
scriptDetails | For smart asset only: asset script and its attributes |
sequenceInBlock | Serial number of the token among those issued in the block (numbering starts at 1) |
# Atomic unit
The amount of token is displayed differently in UIs and in the JSON representation used by the Node REST API. In API requests and responses, amount values are integers indicated in atomic units to avoid precision issues in floating-point calculations.
An atomic unit is the minimum fraction (“cent”) of a token, it is equal to 10–decimals.
The amount of token in JSON is the real quantity multiplied by 10decimals.
For XTN in the example above:
decimals
= 6,- atomic unit is 1/1,000,000 XTN.
"quantity": 999999999395940000
corresponds to 999,999,999,395.94 XTN in UIs,"minSponsoredAssetFee": 150000
corresponds to 0.15 XTN.
# Token Issue
To issue a token, you have to create an Issue transaction within the token parameters:
name
description
decimals
quantity
reissuable
script
(for issuing a smart asset).
There are the following options to send the transaction:
- In the WX Network app developed by the third-party team from the community. See the Token/NFT creation article in the WX Network Help Center.
- In Waves IDE, see the Issuing Smart Asset section.
- Using one of the client libraries. See also the examples in the How to Create Transaction and Send It to Blockchain article.
The transaction fee is 1 WAVES for a regular token or 0.001 WAVES for a non-fungible token (NFT).
Moreover, the token can be issued by the dApp script as a result of the Invoke Script transaction when the callable function result contains the Issue action. The minimum fee for Invoke Script transaction is increased by 1 WAVES for each non-NFT token issued.
# Token Operations
Transfer to another account
Can be done via a Transfer transaction or a Mass Transfer transaction.
A dApp script can transfer the token via a ScriptTransfer script action as a result of an Invoke Script transaction.
Exchange (trade deal)
Three accounts can participate in the exchange: one user creates an order to buy a token, the other creates an order to sell a token. The matcher combines buy and sell orders with suitable parameters and creates an Exchange transaction. For more information on the matcher, see the WX Network documentation.
Burning
Decreases the amount of token on the account and thereby the total amount of the token on the blockchain. Any token owner can burn it, not only the issuer. It is impossible to burning WAVES.
Can be done via a Burn transaction.
A dApp script can burn the token via a Burn script action as a result of the Invoke script transaction.
Payment to dApp
An Invoke Script transaction can contain up to two payments to the dApp. Payment amount and token are available to the callable function.
# Operations Available Only to Issuer
The following token operations can only be performed by the account that issued the token:
Sponsorship setup
The token issuer can enable sponsorship, that is, allow all users to pay a fee in this token (instead of WAVES) for Invoke Script transactions and Transfer transactions. More about sponsorship
Enabling or disabling sponsorship can be done via a Sponsor Fee transaction.
A dApp script can set up sponsorship using a SponsorFee as a result of the Invoke script transaction.
Reissue
Increases the amount of token on the blockchain. The
reissuable
field of token determines whether the token can be reissued.Can be done via a Reissue transaction.
A dApp script can reissue the token via a Reissue script action as a result of the Invoke script transaction.
Replacing the asset script
Can be done via a Set Asset Script transaction. If the token is not a smart asset, that is, the script was not attached when the token was issued, then it is impossible to attach the script later.
Modifying the token name and / or description
Can be done via an Update Asset Info transaction.
# Tokens of Other Blockchains
A token issued on another blockchain cannot be used directly on the Waves blockchain. A new token representing the original one can be issued on the Waves blockchain, and a gateway that pegs the two tokens 1:1 can be deployed. For example, gateway for a ERC20 token can be created using the Waves-ERC20-Gateway framework.