HTTP

Give it a go!

If your blockchain has just been deployed, it will initially contain only the genesis account. You can verify this account using the HTTP interface. For example, on a local setup on port 36002, use the following endpoint:

http://127.0.0.1:36002/v1/account/getGenesisAccount

This will return details of the genesis account, including address, balance, and other initial parameters.

HTTP GET https://{endpoint}/getGenesisAccount
or
curl get https://{endpoint}/getGenesisAccount

If you would like to use our testnet or mainnet as reference, the respective endpoints are below:

Testnet: https://test-node.zetrix.comarrow-up-right

Mainnet: https://node.zetrix.comarrow-up-right

The response content should be as follows:

{
  "error_code" : 0,
  "result" : {
    "address" : "ztxSn8xpL7c2xkxwbreVCs6EZ7KZbBvtDaLtV",
    "assets" : null,
    "balance" : 100000000000000000,
    "metadatas" : null,
    "priv" : {
      "master_weight" : 1,
      "thresholds" : {
        "tx_threshold" : 1
      }
    }
  }
}

The value of address in the returned result is the genesis account address.

HTTP Interfaces

Generating Public and Private Key pairs - Test

  • CURL command

  • Function

    Note: This interface is intended only for testing purposes and should not be used in a production environment. In production, use the SDK or command line tools. Calling this interface on an untrusted or malicious node server may expose your private key, as it only generates a key pair and does not broadcast anything to the blockchain. Use it with caution and only in isolated, secure testing environments.

  • Return value

getAccount

  • CURL command

  • Function

    Return information about the specified account and all its assets and metadata.

  • Parameters

    Parameter
    Description

    address (required)

    Zetrix account address.

    key (optional)

    Specifies the key to retrieve a specific metadata value associated with the account. If left blank, the response will return all metadata linked to the account.

    code, issuer (both optional)

    Asset Code and Asset Issuer: These two fields must be either both be provided or both left blank.

    • If left blank, the response will include all assets associated with the account.

    • If provided, the response will return details only for the specified asset (matching both code and issuer).

  • Return value

    The content returned is as follows:

    If the account does not exist, the content returned is as follows:

getAccountBase

  • CURL command

  • Function

    Return basic information about the specified account, excluding assets and metadata.

  • Parameter

    Parameter
    Description

    address (required)

    Zetrix account address.

  • Return value

    The content returned is as follows:

    If the account does not exist, the content returned is as follows:

getAccountAssets

  • CURL command

  • Function

    Return the asset information of the specified account.

  • Parameters

    Parameter
    Description

    address (required)

    Zetrix account address.

    code, issuer (both optional)

    Asset Code and Asset Issuer: These two fields must be either both be provided or both left blank.

    • If left blank, the response will include all assets associated with the account.

    • If provided, the response will return details only for the specified asset (matching both code and issuer).

  • Return value

    The content returned is as follows:

    If the account does not hold any assets, the returned content is typically:

getAccountMetaData

  • CURL command

  • Function

    Return the metadata information of the specified account.

  • Parameters

    Parameter
    Description

    address (required)

    Zetrix account address.

    key (optional)

    Specify the key value in the metadata

  • Return value

    The content returned is as follows:

    If the account does not have metadata, return the content:

getTransactionHistory

  • CURL command

  • Function

    Return the completed transaction history.

  • Parameters

    Parameter
    Description

    hash

    Query using the transaction hash, which is its unique identifier.

    ledger_seq

    Query all transactions in the specified block

    Note: The constraint between the two parameters operates as a logical AND. If both are specified, the system will query the specific transaction within the specified block.

  • Return value

    The content returned is as follows:

    Note: Below are two transactions; the second one creates a contract account. Carefully review the error_desc field for any execution errors or issues during processing.

    If no transaction is found, the response will be:

getTransactionCache

  • CURL command

  • Function

    If a transaction has been submitted successfully but not yet executed, the response will include the transaction details with a status indicating it is pending or not yet executed, and error_code will typically be 0, with execution fields left unset

  • Parameters

    Parameter
    Description

    hash

    Use the transaction hash, which is its unique ID, to query specific transaction details.

    limit

    Query multiple (N) transactions currently in the transaction queue to view their pending processing status.

    Note: The constraint between the two parameters functions as a logical OR. If both parameters are provided, the system will prioritize and perform a hash-based query.

  • Return value

    The response will returned is as follows:

    If no transaction is found, the response will be:

getLedger

  • CURL command

  • Function

    Return information about block header.

  • Parameters

    Parameter
    Description

    seq

    The ledger serial number specifies a particular block; if left blank, the latest (current) ledger is returned.

    with_validator

    By default, this is set to false, so the list of verification nodes will not be displayed.

    with_consvalue

    By default, this is set to false, and the consensus value is not displayed.

    with_fee

    By default, this is set to false, so the cost configuration is not shown.

  • Return value

    Return response as follows:

    If no ledger is found, the following response is returned:

multiQuery

  • CURL Command

  • Function

    Returns multiple results based on the provided query list.

  • Here, the request body should contain the query list. For example:

  • Return

getTransactionBlob

  • CURL command

  • Function

    Returns both the transaction hash and the hexadecimal string representing the serialized transaction.

  • Here, the request body field transfer contains the transaction data. For the specific JSON structure and parameter definitions, refer to the Transaction Structure section.

  • Return value

submitTransaction

  • CURL command

  • Function

    Send the serialized transaction along with the signature list to the blockchain for processing and execution.

  • Request example:

  • Keywords in JSON

    Parameter
    Type
    Description

    transaction_blob

    string

    The serialized transaction is represented in a hexadecimal string format, which encodes the transaction's binary data for transmission and verification.

    sign_data

    string

    The signed data should be in hexadecimal format and represents the signature generated from the transaction_blob. Note: Before signing, convert transaction_blob to a byte stream—do not sign the hexadecimal string directly.

    public_key

    string

    The public key must be provided in hexadecimal format, corresponding to the private key used to sign the transaction.

  • Return value

    Note: The transaction is submitted and executed successfully.

callContract

  • CURL command

  • Function

    In Zetrix's smart contract module, a sandbox environment is provided for safe debugging. During debugging, neither the blockchain state nor the contract state is modified. Zetrix offers the callContract interface specifically for this purpose it allows you to test smart contracts either by referencing a deployed contract on the public chain or by passing local contract code as parameters. Since this interface does not submit actual transactions, no transaction fee is required.

  • Request example:

  • Keywords in JSON

    Keyword
    Type
    Description

    contract_address

    string

    The smart contract address to be called must be provided; if it cannot be found in the database, an error will be returned. If left blank, the system will default to using the content provided in the code field.

    code

    string

    The code field contains the contract code to be debugged. If contract_address is not provided, the system will use the code field. If both contract_address and code are empty, an error will be returned.

    input

    string

    Pass the parameters to the contract to be called

    contract_balance

    string

    The initial Gas balance assigned to the contract

    fee_limit

    int64

    The transaction fee

    gas_price

    int64

    The price of gas

    opt_type

    int

    0: call the contract's read-write interface init, 1: call the contract's read-write interface main, 2: call the read-only interface query

    source_address

    string

    Simulate the original address of the contract called

  • Return value

testTransaction

  • CURL command

  • Function

    The evaluation fee is fixed and does not depend on the account balance. Both the originating account and the target account involved in a transaction must exist in the system. However, when creating a new account, the target address is not required to pre-exist in the system.

  • Request example:

  • Keywords in JSON

    Keyword
    Type
    Description

    source_address

    string

    The original address of the simulated transaction refers to the sender's address that initiates the contract call during debugging.

    nonce

    int64

    Unique transaction sequence number.

    signature_number

    int64

    Signature count; defaults to 1 if unset.

    metadata

    string

    Optional, the number of signatures

    operations

    array

    Operation List: The transaction's payload defining its intended actions. Refer to Operations Structure for details.

  • Return value

Transaction Structure

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    source_address

    string

    The original address of the simulated transaction refers to the sender's address that initiates the contract call during debugging.

    nonce

    int64

    Unique transaction sequence number.

    fee_limit

    int64

    Fee Limit: The maximum fee allowed for the transaction.

    • If successful, the actual fee is charged.

    • If failed, the full fee limit is charged. Unit: UGas (1 Gas = 10⁶ UGas).

    gas_price

    int64

    Gas Price: Used to calculate the handling fee per operation and the transaction byte fee. Unit: UGas (1 Gas = 10⁶ UGas).

    ceil_ledger_seq

    int64

    Optional: Sets a block height limit for the transaction an advanced feature to control when the transaction can be included.

    operations

    array

    Operation List: Defines what the transaction is intended to perform. Refer to Operations Structure for detailed information.

    metadata

    string

    Optional: A user-defined field that can be left blank or used to include a note.

Operations Structure

The corresponding operations in the JSON structure of the transaction can contain one or more operations.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    type

    int

    Operation Code: Identifies the specific action to perform. Different codes correspond to different operations. See Operation Codes for more details.

    source_address

    string

    Optional: Specifies the source account for the operation. If left blank, it defaults to the transaction’s source account.

    metadata

    string

    Optional: A custom field that can remain empty or include a user-defined note.

    create_account

    JSON

    Creating Accounts operation

    issue_asset

    JSON

    Issuing Assets operation

    pay_asset

    JSON

    Transferring Assets operation

    set_metadata

    JSON

    Setting Metadata operation

    pay_coin

    JSON

    Transferring Gas Assets operation

    log

    JSON

    Recording Logs operation

    set_privilege

    JSON

    Setting Privileges operation

Operation Codes

Operation Code
Operation
Description

1

create_account

Creating Accounts

2

issue_asset

Issuing Assets

3

pay_asset

Transferring Assets

4

set_metadata

Setting Metadata

7

pay_coin

Transferring Gas Assets

8

log

Recording Logs

9

set_privilege

Setting Privileges

Creating Accounts

The source account creates a new account on the blockchain. Creating Accounts are divided into Creating Normal Accounts and Creating Contract Accounts.

Creating Normal Accounts

Note: Both master_weight and tx_threshold must be 1 in the current operation.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    dest_address

    string

    Target Account Address: Required when creating a normal account; this field cannot be left empty.

    init_balance

    int64

    The initial Gas value of the target account, in UGas, 1 Gas = 10^6 UGas

    master_weight

    int64

    The master weight of the target account, which ranges [0, MAX(UINT32)]

    tx_threshold

    int64

    The threshold for initiating a transaction below which the transaction cannot be initiated, which ranges ​​[0, MAX(INT64)]

  • Complete transaction structure

  • Query

    The account information is queried through the getAccount interface.

Creating Contract Accounts

Note: In the current operation, master_weight must be 0 and tx_threshold must be 1.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    payload

    string

    Contract code

    init_balance

    int64

    The initial Gas value of the target account, in UGas, 1 Gas = 10^6 UGas

    init_input

    string

    Optional: Specifies the input parameters for the init function in the contract code.

    master_weight

    int64

    Master Weight: Defines the main authority level of the target account.

    tx_threshold

    int64

    The threshold for initiating a transaction below which it is not possible to initiate a transaction.

  • Complete transaction structure

  • Query

    • The account information is queried through the getAccount interface.

    • Query with the getTransactionHistory interface, and the result is as follows:

Issuing Assets

  • Function

    The source account in this operation issues a digital asset, which will appear in its asset balance upon successful execution.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    code

    string

    The code of the asset to be issued, which ranges [1, 64]

    amount

    int64

    The amount of the asset to be issued, which ranges (0, MAX(int64))

  • Complete transaction structure

Transferring Assets

Note: If the target account is a contract account, the current operation triggers the contract execution of the target account.

  • Function

    The source account of this operation transfers an asset to the target account.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    dest_address

    string

    Address of the target account

    issuer

    string

    Address of the issuer

    code

    string

    Asset code which ranges [1, 64]

    amount

    int64

    Amount of the asset which ranges (0,MAX(int64))

    input

    string

    Optional: If the target account is a contract, the input is passed to the main function's argument. This setting is ignored for normal accounts.

  • Complete transaction structure

Setting Metadata

  • Function

    The source account of this operation modifies or adds metadata to the metadata table.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    key

    string

    Keyword of metadata, which ranges (0, 1024].

    value

    string

    Content of metadata, which ranges [0, 256K].

    version

    int64

    Optional: Metadata version number, default is 0.

    • 0: No version limit

    • >0: Must match the specified version

    • <0: Invalid value

  • Complete transaction structure

Setting Privileges

  • Function

    Set the signer weights and the thresholds required for different operations. For more details, refer to Assignment of Control Rights.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    master_weight

    string

    Optional: Defaults to "", which refers to the account’s master weight.

    • "": Do not modify the value

    • "0": Set master weight to 0

    • "1" to "MAX(UINT32)": Set weight to the specified value

    • Any other input: Invalid value

    signers

    array

    Optional: A list of signers involved in the operation. Defaults to an empty object, which means no signers are set.

    address

    string

    Signer Address: The address of the signer to be set, which must comply with the address verification rules.

    weight

    int64

    Optional: Defaults to 0.

    • 0: Deletes the signer

    • (0, MAX(UINT32)]: Sets the signer’s weight to the specified value

    • Other values: Invalid

    tx_threshold

    string

    Optional: Defaults to "", indicating the account’s minimum privilege (tx_threshold).

    • "": Do not modify the value

    • "0": Set tx_threshold to 0

    • "1" to "MAX(INT64)": Set to specified weight

    • Other values: Invalid

    type_thresholds

    array

    Optional: A list of thresholds required for different operations. Defaults to an empty object, which means no thresholds are set.

    type

    int

    To indicate a certain operation type (0, 100]

    threshold

    int64

    Optional: Defaults to 0.

    • 0: Deletes the operation type

    • (0, MAX(INT64)]: Sets the operation’s threshold to the specified value

    • Other values: Invalid

  • Complete transaction structure

Transferring Gas Assets

Note: If the target account is a contract account, the current operation triggers the contract execution of the target account.

  • Function

    Two functions:

    1. The source account of this operation transfers a Gas asset to the target account.

    2. The source account of this operation creates a new account on the blockchain.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    dest_address

    string

    The target account

    amount

    array

    Optional: A list of signers to be configured. Defaults to an empty object, which means no signer settings will be applied.

    input

    string

    Optional: If the target is a contract account, the input is passed to the main function of the contract code. This setting is ignored for normal accounts.

  • Complete transaction structure

Recording Logs

  • Function

    The source account of this operation writes the log to the blockchain.

  • In JSON format

  • Keywords in JSON

    Keyword
    Type
    Description

    topic

    string

    Log topic and the parameter length is (0,128]

    datas

    array

    Log content. The length of each element is (0,1024]

  • Complete transaction structure

Assignment of Control Rights

When creating an account, you can define its control rights using the priv field. This allows you to assign signer weights and operation thresholds.

Example

In this example, the account ztxSW512jUyDASna878ECgZ4QFyhh6AtEJP6E initiates a transaction containing a single operation:

  • Create a new account with address ztxSX1SypC33doY4a5MYYr5zBZUvB33kKHdAo

  • The account creation is completed by transferring Gas to the new account during the operation.

Assembling Transactions

Referring to the structure of Transaction Structure, the following three steps are required:

  1. Obtaining the account nonce value

  2. Assembling operations

  3. Generating transaction objects

Obtaining the Account Nonce Value

In a transaction structure, it's essential to confirm the serial number (nonce) of the initiating account. To do this:

  1. Use the getAccountBase interface to retrieve the current nonce value of the initiating account.

  2. Increment the nonce by 1 to set the correct value for the new transaction.

This ensures transaction ordering and prevents replay.

The interface call is as follows:

The following content is returned:

Assembling Operations

According to the structure of Operations Structure, Operation Codes, and Transferring Gas Assets structure, the JSON format of the generation operation is as follows:

Generating Transaction Objects

In this example, after obtaining the account's nonce value of 20, the new transaction’s serial number is set to 21. Based on the assembled operation structure, the transaction JSON format will look like this:

Serializing Transaction Data

This is done through the getTransactionBlob interface.

The interface call is as follows:

Return the following content:

Signing Signatures

Signing signatures is to sign the value of transaction_blob in getTransactionBlob with the private key of ztxSW512jUyDASna878ECgZ4QFyhh6AtEJP6E and generate a public key. For details, please refer to keypair. The resulting signature data is as follows:

Submitting Transaction Data

According to the signature data obtained by Signing Signatures and the transaction_blob obtained by Serializing Transaction Data, the JSON format of the body in the submitTransaction interface is generated as follows:

The interface call is as follows:

Return the following content:

Querying the Transaction Result

According to the hash obtained by the submitTransaction interface, confirm whether the transaction is executed successfully by the getTransactionHistory interface (check whether error_code under transactions is equal to 0).

The interface call is as follows:

Return the following result:

Error Codes

The error code is composed of two parts:

  • error_code : Error code, approximate error classification

  • error_desc : Error Description, which can accurately find the error specific information from the error description

The error list is as follows:

Error code
Name
Description

0

ERRCODE_SUCCESS

Successful operation

1

ERRCODE_INTERNAL_ERROR

Inner service defect

2

ERRCODE_INVALID_PARAMETER

Parameters error

3

ERRCODE_ALRGasDY_EXIST

Objects already exist, such as repeated transactions submitted

4

ERRCODE_NOT_EXIST

Objects do not exist, such as null account, transactions and blocks etc

5

ERRCODE_TX_TIMEOUT

Transactions expired. It means the transaction has been removed from the buffer, but it still has probability to be executed

7

ERRCODE_MATH_OVERFLOW

Math calculation is overflown

20

ERRCODE_EXPR_CONDITION_RESULT_FALSE

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

ERRCODE_EXPR_CONDITION_SYNTAX_ERROR

The syntax of the expression returns is false. It means that the TX must fail

90

ERRCODE_INVALID_PUBKEY

Invalid public key

91

ERRCODE_INVALID_PRIKEY

Invalid private key

92

ERRCODE_ASSET_INVALID

Invalid assets

93

ERRCODE_INVALID_SIGNATURE

The weight of the signature does not match the threshold of the operation

94

ERRCODE_INVALID_ADDRESS

Invalid address

97

ERRCODE_MISSING_OPERATIONS

Absent operation of TX

98

ERRCODE_TOO_MANY_OPERATIONS

Over 100 operations in a single transaction

99

ERRCODE_BAD_SEQUENCE

Invalid sequence or nonce of TX

100

ERRCODE_ACCOUNT_LOW_RESERVE

Low reserve in the account

101

ERRCODE_ACCOUNT_SOURCEDEST_EQUAL

Sender and receiver accounts are the same

102

ERRCODE_ACCOUNT_DEST_EXIST

The target account already exists

103

ERRCODE_ACCOUNT_NOT_EXIST

Accounts do not exist

104

ERRCODE_ACCOUNT_ASSET_LOW_RESERVE

Low reserve in the account

105

ERRCODE_ACCOUNT_ASSET_AMOUNT_TOO_LARGE

Amount of assets exceeds the limitation ( int64 )

106

ERRCODE_ACCOUNT_INIT_LOW_RESERVE

Insufficient initial reserve for account creation

111

ERRCODE_FEE_NOT_ENOUGH

Low transaction fee

114

ERRCODE_OUT_OF_TXCACHE

TX buffer is full

120

ERRCODE_WEIGHT_NOT_VALID

Invalid weight

121

ERRCODE_THRESHOLD_NOT_VALID

Invalid threshold

144

ERRCODE_INVALID_DATAVERSION

Invalid data version of metadata

146

ERRCODE_TX_SIZE_TOO_BIG

TX exceeds upper limitation

151

ERRCODE_CONTRACT_EXECUTE_FAIL

Failure in contract execution

152

ERRCODE_CONTRACT_SYNTAX_ERROR

Failure in syntax analysis

153

ERRCODE_CONTRACT_TOO_MANY_RECURSION

The depth of contract recursion exceeds upper limitation

154

ERRCODE_CONTRACT_TOO_MANY_TRANSACTIONS

the TX submitted from the contract exceeds upper limitation

155

ERRCODE_CONTRACT_EXECUTE_EXPIRED

Contract expired

160

ERRCODE_TX_INSERT_QUEUE_FAIL

Failed to insert the TX into buffer

Last updated