Asset Issuance
Zetrix Asset Issuance Example
Scenario Description
The token issuer issues 1000000000 assets on Zetrix, the token code is GLA and the token name is Global. The specific information is as follows:
name
yes
Global
Token name
code
yes
GLA
Token code
totalSupply
yes
1000000000
Total supply of assets
decimals
yes
8
Token decimal
description
no
Token description
icon
no
Token ICON
version
yes
1.0
The version number
Explain:
code: Capitalized spell is recommended.
decimals: The number of decimal places which is in the range of 0~8, and 0 means no decimal place.
totalSupply: The total supply of the assets which are in the range of 0~2^63-1, and 0 means no limitation for the assets. For example, when issuing 10000 assets with 8 decimal places, the value of totalSupply is 1000000000000 (10 ^ 8 * 10000)
icon: Base64 bit encoding, and the size of the icon file is less than 32k,200*200 pixels is recommended.
version: The version number of the protocol, and its present value is 1.0.
Development Process for Token Issuing
In this document we use the Java language as an example to create an token issuer and issue 1000000000 assets.
Note: Please replace the [AccountAddressOfTokenIssuer] in the examples with the account address of the token to be issued by the token issuer. And replace the [AccountPrivateKeyOfTokenIssuer] in the examples with the account private key of the token to be issued by the token issuer.
Creating an SDK Instance
We create an instance with the following code and set its url (the IP and Port of the node).
In Zetrix, the generation time for each block is 10 seconds, and only one confirmation is needed for a transaction to get the final state.
The environment description is as follows:
Zetrix Testnet
seed1-node.zetrix.com
If you require ZETRIX coins in the testnet, you may use link below: https://faucet.zetrix.com/
Creating an Account for the Token Issuer
The specific code for creating an account for the token issuer is as follows:
The return value is as follows:
Note: The account created above is not activated.
Activating the Account of Token Issuer
The non-activated account needs to be activated by an activited account. Please skip this section if your issuer account is already activated.
Note: You can transfer Gas of the account who is activated to the account who is not activated to activate it.
Getting the Nonce Value
Each account maintains a nonce value which starts at 1. The nonce value represents the amount of transactions in the account.
The code used to get the nonce value is as follows:
The return value is as follows:
Grouping Oprations for Token Issuing
A transaction can consist of multiple operations, each pointing to a specific transaction content.
Two operations are needed to issue assets: AssetIssueOperation
, and AccountSetMetadataOperation
.
The specific code for grouping operations for token issuing is as follows:
Serializing Transactions
Transactions are serialized for network transmission.
Note:
feeLimit: The maximum fee the transaction initiator will pay for the transaction, and please fill in 50.03 Gas when the operation is issuing assets.
nonce: The nonce value of this transaction initiator, which can be obtained by adding 1 to the current nonce value.
The specific code for serializing transactions is as follows. In the example, nonce
is the series number of account obtained by calling getAccountNonce
, and operations
is the operations for issuing assets obtained by calling buildOperations
.
The return value is as follows:
Signing Transactions
All transactions need to be signed to be valid. The signing result includes the signature data and the public key.
The specific code for signing transactions is as follows. In the example, transactionBlob
is the string of the seralized transactions obtained by calling seralizeTransaction
.
The return value is as follows:
Sending Transactions
Sending transactions refers to sending the serialized transactions and the signatures to Zetrix.
The specific code for sending transactions is as follows. In the example, transactionBlob
is the string of the seralized transactions obtained by calling seralizeTransaction, and signatures
is the signature data obtained by calling signTransaction.
The return value is as follows:
Checking the Result of the Transaction Execution
Note: The returned result of transactions sent represents whether the transaction is submitted successfully.
The specific code to call the interface is as follows. In the example, txHash
is the hash value of transactions which is the unique identification obtained by calling submitTransaction.
The return value is as follows: 0
0
Successful operation
1
Inner service defect
2
Parameters error
3
Objects already exist, such as repeated transactions
4
Objects do not exist, such as null account, transactions and blocks etc.
5
Transactions expired. It means the transaction has been removed from the buffer, but it still has probability to be executed.
7
Math calculation is overflown
20
The expression returns false. It means the TX failed to be executed currently, but it still has probability to be executed in the following blocks .
21
The syntax of the expression returns are false. It means that the TX must fail.
90
Invalid public key
91
Invalid private key
92
Invalid assets
93
The weight of the signature does not match the threshold of the operation.
94
Invalid address
97
Absent operation of TX
98
Over 100 operations in a single transaction
99
Invalid sequence or nonce of TX
100
Low reserve in the account
101
Sender and receiver accounts are the same
102
The target account already exists
103
Accounts do not exist
104
Low reserve in the account
105
Amount of assets exceeds the limitation ( int64 )
106
Insufficient initial reserve for account creation
111
Low transaction fee
114
TX buffer is full
120
Invalid weight
121
Invalid threshold
144
Invalid data version of metadata
146
exceeds upper limitation
151
Failure in contract execution
152
Failure in syntax analysis
153
The depth of contract recursion exceeds upper limitation
154
the TX submitted from the contract exceeds upper limitation
155
Contract expired
160
Fail to insert the TX into buffer
11060
BlockNumber must bigger than 0
11007
Failed to connect to the network
12001
Request parameter cannot be null
20000
System error
Last updated