Asset Issuance

Zetrix Asset Issuance Example

Scenario Description

The token issuer issues 1,000,000,000 GLA (Global) assets on Zetrix with the token code GLA and name Global.

Field Name
Required
Example
Description

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: Defines the number of decimal places; must be in the range of 0 to 8. A value of 0 means the asset has no decimal places.

  • totalSupply: Specifies the total number of assets to be issued. Must be within 0 to 2⁶³−1. A value of 0 means the asset has no supply limit.

  • Example: Issuing 10,000 assets with 8 decimal places → totalSupply = 10,000 × 10⁸ = 1,000,000,000,000.

  • icon: Provided as a Base64-encoded image. File size must be under 32 KB, and a 200×200 pixels dimension is recommended.

  • version: Indicates the protocol version. The current value is 1.0.

Development Process for Token Issuing

In this document, we use Java as an example to create a token issuer and issue 1,000,000,000 assets on Zetrix.

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:

Network Environment
IP

Zetrix Testnet

seed1-node.zetrix.com

If you require ZETRIX coins in the testnet, you may use link below: https://faucet.zetrix.com/arrow-up-right

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 must be activated by an already activated account. You may skip this step 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 include multiple operations, each representing a specific transaction instruction or content.

Two operations are needed to issue an 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

Error code
Description

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