HTTP
Have a Try
If your blockchain has just been deployed, there is only a genesis account in the blockchain system. You can check the genesis account through the http interface (Example for localhost and 36002):
You may use https://node.zetrix.com or https://test-node.zetrix.com/ as the endpoint.
For reference, to determine where exactly is the endpoint, refer below.
Mainnet: https://node.zetrix.com
Testnet: https://test-node.zetrix.com
The content returned is as follows.
The value of address
in the returned result is the genesis account.
You can query any account through the getAccount interface.
HTTP Interfaces
Generating Public and Private Key pairs - Test
CURL command
Function
Note: This interface is only for testing purposes. Do not use this interface in a production environment (SDK or command line used in production environment), because after calling this interface, if the node server is evil, the account's private key will be leaked. This interface only generates a public-private key pair and does not write to the entire network blockchain.
Return value
getAccount
CURL command
Function
Return information about the specified account and all its assets and metadata.
Parameters
Parameter Description address
The account address, required
key
The value of the key specified in the metadata of the account. If not filled, the returned result contains all the metadata
code, issuer
The asset code, and asset issuer. These two variables are either filled in at the same time or not filled at the same time. If you do not fill in, the returned results contain all the assets. If filled in, only the code and issuer are displayed in the returned results.
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
The account address, required
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
The account address, required
code, issuer
The issuer represents the asset issuance account address, and code represents the asset code. Only the correct code&issuer can be filled in at the same time to display the specified asset correctly or all assets will be displayed by default
Return value
The content returned is as follows:
If the account does not have an asset, the content returned is as follows:
getAccountMetaData
CURL command
Function
Return the metadata information of the specified account.
Parameters
Parameter Description address
The account address, required
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 with the hash, the unique identifier of the transaction
ledger_seq
Query all transactions in the specified block
Note: The constraint generated by the above two parameters is a logical AND. If you specify two parameters at the same time, the system will query the specified transaction in the specified block.
Return value
The content returned is as follows:
Note: There are two transactions below, and the 2nd transaction is a transaction to create a contract account. Please note the contents of the error_desc field.
If no transaction is found, return the following content:
getTransactionCache
CURL command
Function
Return a transaction that is submitted successfully but not yet executed.
Parameters
Parameter Description hash
Query with the hash, the unique identifier of the transaction
limit
Query N transactions being processed in the transaction queue
Note: The constraint generated by the above two parameters is a logical OR. If you specify two parameters at the same time, the system will hash the query.
Return value
The content returned is as follows:
If no transaction is found, return the following content:
getLedger
CURL command
Function
Return information about block header.
Parameters
Parameter Description seq
The serial number of the ledger. If not filled, return the current ledger
with_validator
By default is false and the list of verification nodes is not displayed
with_consvalue
The default is false, and no consensus value is displayed
with_fee
The default is false, and the cost configuration is not displayed
Return value
Return the content as follows:
Return the following content if no ledger is queried:
{ "error_code" : 4, "result" : null } ```
multiQuery
CURL Command
Function
Returning multiple query results according to the query list.
The body is in json format
Here the body pass is the query list. For example:
Return
getTransactionBlob
CURL command
Function
Return the transaction hash and the hexadecimal string after the transaction is serialized.
The body is in json format
Here body transfer is the transaction data. For specific json format and parameters, see Transaction Structure. Example:
Return value
submitTransaction
CURL command
Function
Send the serialized transaction and signature list to the blockchain.
The body is in json format
Keywords in json
Parameter Type Description transaction_blob
string
The hexadecimal format after the transaction is serialized
sign_data
string
Data signed, in hexadecimal format. Its value is the signature data obtained by signing (transaction) the transaction_blob. Note: when signing, you must first convert
transaction_blob
into byte stream and then sign, and do not directly sign hexadecimal stringpublic_key
string
The public key, in hexadecimal format
Return value
Note: The transaction is submitted and executed successfully.
callContract
CURL command
Function
In the design of the smart contract module, we provide a sandbox environment for debugging contracts, and the state of the blockchain and contract is not changed during debugging. On Zetrix, we provide you with the
callContract
interface to help you debug the smart contract. The smart contract can be stored in the public chain, or it can be tested by uploading the local contract code by parameters. ThecallContract
interface will not be sent. Therefore, there is no need to pay for the transaction fee.The body is in json format
Keywords in json
Keyword Type Description contract_address
string
The smart contract address that is called, or an error is returned if it is not quired from the database. If you left it blank, the content of the code field is read by default.
code
string
The contract code to be debugged, if the
contract_address
is empty, the code field is used, and if the code field is also empty, an error is returnedinput
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 interfacemain
, 2: call the read-only interfacequery
source_address
string
Simulate the original address of the contract called
Return value
testTransaction
CURL command
Function
The evaluation fee does not change the evaluation based on the account balance. The original account and the target account involved in the transaction must exist in the system, but the target address for creating the account does not have to be in the system.
The body is in json format
Keywords in json
Keyword Type Description source_address
string
The original address of the simulated transaction
nonce
int64
Add 1 based on the original account number
signature_number
int64
The number of signatures, the default is 1; the system will be set to 1 if not filled
metadata
string
Optional, the number of signatures
operations
array
Operation list. The payload of this transaction, which is what the transaction wants to do. See Operations Structure for details
Return value
Transaction Structure
In json format
Keywords in json
Keyword Type Description source_address
string
The source account of the transaction, which is the account of the transaction initiator. When the transaction is successful, the nonce field of the source account will be automatically incremented by 1. The nonce in the account number is the number of transactions executed by this account
nonce
int64
Its value must be equal to the current nonce+1 of the source account of the transaction, which is designed to prevent replay attacks. If you want to know how to query the nonce of an account, you can refer to getAccount. If the account queried does not display the nonce value, the current nonce of the account is 0.
fee_limit
int64
The maximum fee that can be accepted for this transaction. The transaction will first charge a fee based on this fee. If the transaction is executed successfully, the actual cost will be charged, otherwise the fee for this field will be charged. The unit is UGas, 1 Gas = 10^6 UGas
gas_price
int64
It is used to calculate the handling fee for each operation and also involved in the calculation of the transaction byte fee. The unit is UGas, 1 Gas = 10^6 UGas
ceil_ledger_seq
int64
Optional, the block height restriction for this transaction, which is also an advanced feature
operations
array
The operation list. The payload of this transaction, which is what the transaction wants to do. See Operations Structure for more details
metadata
string
Optional, a user-defined field that can be left blank or filled in 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, different operation codes perform different operations, see Operation Codes for details
source_address
string
Optional, the source account of the operation, that is, the operator of the operation. When not filled in, the default is the same as the source account of the transaction
metadata
string
Optional, a user-defined field that can be left blank or filled in a note
create_account
json
The Creating Accounts operation
issue_asset
json
The Issuing Assets operation
pay_asset
json
The Transferring Assets operation
set_metadata
json
The Setting Metadata operation
pay_coin
json
The Transferring Gas Assets operation
log
json
The Recording Logs operation
set_privilege
json
The 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
andtx_threshold
must be 1 in the current operation.
In json format
Keywords in json
Keyword Type Description dest_address
string
The address of the target account. When creating a normal account, it cannot be 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 andtx_threshold
must be 1.
In json format
Keywords in json
Keyword Type Description payload
string
The contract code
init_balance
int64
The initial Gas value of the target account, in UGas, 1 Gas = 10^6 UGas
init_input
string
Optional, the input parameter of the init function in the contract code
master_weight
int64
The master weight 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 of this operation issues a digital asset, and this asset appears in the asset balance of the source account after 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