Last Tuesday, the Waves team published a new version of their fullnode for testnet. This new release included asset creation. Currently this feature lacks a bit of documentation, but with the help of people on the #testnet-maintainers slack channel, we were able to figure out how it works (special thanks to @mx for the support). In order to provide a starting point for testing of asset creation and asset transfer, the following describes first how to issue a new asset, second how to check if the asset was successfully issued and third how to transfer assets to other users.
Asset creation
If you go to the Swagger UI of your node, you will find a new set of endpoints starting with /assets. The first endpoint here /assets/issue allows to issue new assets. In order to do so, one needs to prepare a JSON description of the asset like the following one:
{
"name": "DtasCCmi3uVMUAsBNUzbo9",
"quantity": 1000000,
"description": "AhuKyNZ1eFb8kGbYy89WvPqqf4unhhPuu",
"sender": "3Mvtz6QNaxBgS2o8nBkJLhaeDKE38U8V68Y",
"decimals": 8,
"reissuable": false,
"fee": 100000000
}
The different attributes describe the following parameters of the asset to create:
- name: This is the name of the asset. According to the code (scorex.transaction.assets.IssueTransaction), this needs to be a Base58 encodable string. Therefore, certain characters like "." or spaces are not allowed.
- quantity: The amount of tokens you want to create for the new asset
- description: This is the description of the asset. According to the code (scorex.transaction.assets.IssueTransaction), this needs to be a Base58 encodable string. Therefore, certain characters like "." or spaces are not allowed.
- sender: Here you need to provide the address that creates the tokens. Be aware that this address needs to hold a minimal number of tokens in order to allow for asset creation.
- decimals: This describes the amount of decimals that are applicable for the newly created asset. Therefore, this parameter allows to define how granular you can later on divide the tokens of the asset. This needs to be a value between zero and eight.
- reissuable: According to this document, it describes whether the amount of available tokens could be enlarged later on.
- fee: This describes fee offered to miners, in wavelets. The minimal fee is 100000000.
After describing these parameters, the new asset could be issued by pressing the according button. As the result you should see something like this:
{
"type": 3,
"id": "84w5GaQfGrceYwdXuPTBgLKz7WccWiJUHJbe6oP53XQ5",
"sender": "3Mvtz6QNaxBgS2o8nBkJLhaeDKE38U8V68Y",
"assetId": "84w5GaQfGrceYwdXuPTBgLKz7WccWiJUHJbe6oP53XQ5",
"name": "DtasCCmi3uVMUAsBNUzbo9",
"description": "AhuKyNZ1eFb8kGbYy89WvPqqf4unhhPuu",
"quantity": 1000000,
"decimals": 8,
"reissuable": false,
"fee": 100000000,
"timestamp": 1475859483143,
"signature": "4DFpobWp27a9q9reR4YbLtaw2UjA12MVSEMDKaejSpGdNBsRpYfxgNxznzGwJYH8jZPgLVUN5Ln4wH9waVz1d5FA"
}
This basically repeats the parameters described before, plus some additional information like the signature. If everything worked out as planned, the new asset should be created and the quantity of tokens should be available for the address that issued the tokens.
Check if tokens are available
In order to check if the tokens are really available and the issuing of the new asset worked out correctly, the second endpoint /assets/balance/{address}/{assetId} could be used. Obviously, in order to execute this endpoint, the address holding the tokens and the id of the asset need to be provided. For testing the above example, the address 3Mvtz6QNaxBgS2o8nBkJLhaeDKE38U8V68Y and the asset id 84w5GaQfGrceYwdXuPTBgLKz7WccWiJUHJbe6oP53XQ5 could be provided and the result should look like this:
{
"address": "3Mvtz6QNaxBgS2o8nBkJLhaeDKE38U8V68Y",
"assetId": "84w5GaQfGrceYwdXuPTBgLKz7WccWiJUHJbe6oP53XQ5",
"balance": 600000
}
The balance here is lower than the originally created amount of tokens, because some of the tokens have already been transferred. Usually the balance should be exactly the amount that you provided while issuing the asset.
Transferring tokens
Finally, tokens of the new assets should also be transferable to other users. For this use case, the third endpoint /assets/transfer could be used. Therefore, again a JSON description representing the transfer need to be created:
{
"recipient":"3Mow5eB2vAKP5E5WutiURYPFhRqp8mAHKvY",
"assetIdOpt":"84w5GaQfGrceYwdXuPTBgLKz7WccWiJUHJbe6oP53XQ5",
"amount": 10,
"feeAmount": 10000,
"attachment": "test",
"sender": "3Mvtz6QNaxBgS2o8nBkJLhaeDKE38U8V68Y"
}
This will basically transfer the amount of 10 tokens of the newly created asset to the recipient address. The result should look something like this:
{
"type": 4,
"id": "BwzcLz7H9GAckcxhA7QwWq6nHoJBKtnmWj9sakakskp9",
"sender": "3Mvtz6QNaxBgS2o8nBkJLhaeDKE38U8V68Y",
"recipient": "3Mow5eB2vAKP5E5WutiURYPFhRqp8mAHKvY",
"assetId": "84w5GaQfGrceYwdXuPTBgLKz7WccWiJUHJbe6oP53XQ5",
"amount": 10,
"feeAsset": null,
"feeAmount": 10000,
"timestamp": 1475922237050,
"attachment": "test",
"signature": "4gcJrB6PU1omQJEjmxygBbnft8ftDZaGMEa743yr9bn7scCSEBEaZLKWJ45kd5RZiVgQq1CuHiqNthJJSVtEShpb"
}
Finally, this shows that the asset mechanism works nicely on the Waves platform. A couple of additional Web Service endpoints, e.g., for querrying assets of a given address, will probably be necessary and other endpoints for reasons of convenience would be nice. This will probably be implemented in future releases. Additionally, the creation of assets will also be possible from the LiteClient, so that fiddling with the JSON description and the endpoints directly will not be necessary in the future.
Nice work.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
followed!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Ok this is going to take me a minute to comprehend.. I've got waves tokens from the ICO and am trying to figure out how to use them with steemit assets. Do you have a tuturiol on how to do so? Thanks, .. upvoted and followed and shared
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit