Академический Документы
Профессиональный Документы
Культура Документы
Introduction
This document is the user guide for the NULS Java SDK which describes instructions regarding
the basic functional interfaces provided by the NULS service, including accounts, transactions,
blocks, etc.
Agreement
All SDK interfaces uniformly return Result (data explanation enclosed at the end of the
article)
The return object described by each interface refers to the content of the data attribute in
the result.
Except as stated otherwise indicated, Na is taken as the unit for all the NULS in this
document - 1NULS = 100000000 Na
Before running the SDK, it is compulsory to confirm that the NULS node service has
started and functioned properly
JDK 1.8 + is recommended
v0.9.11.1 2018-06- added the interface to get the latest block height and hash(3.6, 3.7)
22 and modified 2.1
Quick start
1.Import file
Import the jar package with the build tool
Maven mode
<dependency>
<groupId>io.nuls.sdk</groupId>
<artifactId>nuls-sdk</artifactId>
<version>0.9.11</version>
</dependency>
//Default
SDKBootstrap.sdkStart();
//Pass the IP and port into NULS service
SDKBootstrap.sdkStart("192.168.1.88", "8001");
import io.nuls.sdk.SDKBootstrap;
import io.nuls.sdk.model.Result;
//Import the named namespace of the corresponding module according to the
requirement
import io.nuls.account.sdk.service.AccountService;
import io.nuls.account.sdk.service.impl.AccountServiceImpl;
public static void main(String[] args) {
SDKBootstrap.sdkStart();
AccountService as = new AccountServiceImpl();
Result = as.createAccount("nuls123456");
}
Account AccountService
Description
When you create an account, you can create a single or multiple accounts with or without a
password based on the parameters passed in;
Successfully created account information will be persisted to the NULS service’s local database.
password String No Set the account password, password length (8~20), must
include both letters and numbers, no spaces.
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data":{
"list": [ //Return a address set that was successfully created ac
counts
"2Cbkwxu34iCjsiHKBjqZDNjoVbLMcJv",
"2Cbkwxu34iCjsiHKBjqZDNjoVbLMcJv"
]
}
}
e.g.
Description
The action of creating an account and returning it completely when offline will not
interact with NULS underlying and persist operation.
Create encrypted off-line accounts (Not saved to the database)
Result.data List<AccountDto>
password String No Set the account password, password length (8~20), must
include both letters and numbers, no spaces.
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data":
{
"list":
[
{
"address": String, Account address
"alias": String, alias
"pubKey": String, public key
"extend": String, extend
"createTime": Long, createTime
"encrypted": boolean, encrypt or not
"priKey": String, Private key (valid only for account cre
ated offline with no password)
(
"encryptedPriKey": String, encrypted PriKey valid only fo
r account created offline with password )
},
{
"address": "2CiBQg72BCLmLqttRpPfp8ECRCBwbdD",
"alias": null,
"pubKey": "020159dc5cc74463f346b71c08dd934a823e9e6fe727d8
d3c577e7d462e1a364bb",
"extend": null,
"createTime": 1529314943624,
"encrypted": true,
"priKey": "",
"encryptedPriKey": "5664f746654fb111e967bb3922910b16340f1
e60ff1b281c7a333179d7b82d6220bb12d1c058d9cd06099d4f443a4cb0"
}
]
}
}
e.g.
Description
Result.data AccountDto
Parameter Type Required Description
API Response
:
A successful call will give you a result similar to this
{
"success": true,
"data": {
"address": String, account address
"alias": String, alias
"pubKey": String, public key
"extend": String, extend
"createTime": Long, create time
"encrypted": boolean, encrypt or not
"priKey": String, Private key (value only if you create an offlin
e account with no password)
(
"encryptedPriKey": String, encrypted PriKey value only if you cre
ate an offline account with password )
}
}
e.g
getAccount("2ChqBTvFXttQsghj8zQpcdv76TQU8G5");
Description
Determined by the account address and the required fee for setting alias name( not include the
fixed cost of setting the 1NULS alias ).
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": 0.01 (NULS as unit)
}
e.g.
getAliasFee("2ChqBTvFXttQsghj8zQpcdv76TQU8G5","factory666");
Description
Result.data List<AccountDto>
pageSize int Yes record the number of the return data per page, with values
ranging from 1 to 100
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": [
{
"address": String, Account address
"alias": String, alias
"pubKey": String, public key
"extend": String, extend
"createTime": Long, time of creation
"encrypted": boolean, encrypt
(
"priKey": String, Private key value only if you create an off
line account with no password )
(
"encryptedPriKey": String, encryptedPrivate key value only if
you create an offline account with password )
},
{
"address": "2Cid96JrTGA2XaNG6zXrRKh18kLUbLP",
"alias": null,
"pubKey": "033da2433ef4ca111bfeefaadd9fe0f5874f3aac5186109f9d
e10a9eed6f48f184",
"extend": null,
"createTime": 1529311250627,
"encrypted": true,
"priKey": null,
"encryptedPriKey": null
}
]
}
e.g.
getAccountList(1, 10);
Description
Result.data String
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "2ChDcC1nvki521xXhYAUzYXt4RLNULS"
}
e.g.
getAddressByAlias("factory666");
Description
Get the account private key based on the account address and password, and returns the
private key string
Result.data String
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "1f9d3ad044e0e1201e117b041f3d2ceedacb44688e57969620f3ad7a4d6e
9d24"
}
e.g.
//Account call with password
getPrikey("2ChqBTvFXttQsghj8zQpcdv76TQU8G5", "nuls123456");
//Account call without password
getPrikey("2ChqBTvFXttQsghj8zQpcdv76TQU8G5");
Description
verify the alias name’s availablity according to the alias name (whether it is reused)
Result
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": false,
"data" {:
"code": "ACT005",
"msg": "xxxxxx...."
}
}
{ // error message
"success": false,
"data" {:
"code": "ACT005",
"msg": "xxxxxx...."
}
}
e.g.
isAliasUsable("factory666");
Description
According to the account address, password, and output address backup account (export.
Keystore file), the keystore exported is encrypted by the current password if the account is
encrypted. Verify account password when importing.
path String Yes The folder where the backup file will be stored. When null is
passed, it will be backed up.
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "/Users/lichao/Downloads/2ChDcC1nvki521xXhYAUzYXt4RLNULS.acco
untkeystore"
}
e.g.
//Backup an account without a password to the current directory
backupAccount("2ChqBTvFXttQsghj8zQpcdv76TQU8G5", null);
//Backup an account with a password to /backup directory
backupAccount("2ChqBTvFXttQsghj8zQpcdv76TQU8G5", "/backup",
"nuls123456");
Result importAccountByKeystore
Description
Import account from keystore file, and if the keystore file is generated by the backup from
encrypted account, it is required to verify the password of the account for backup.
Result
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "2ChDcC1nvki521xXhYAUzYXt4RLNULS"
}
e.g.
//Import an account with password
importAccountByKeystore("/backup/XXXXXX.keystore", "nuls123456", true);
importAccountByKeystore(fileReader, "nuls123456", true);
//Import an account without password
importAccountByKeystore("/backup/XXXXXX.keystore", false);
importAccountByKeystore(fileReader, false);
Description
Result
overwrite boolean Yes true: perform an override import; False: if the account
already exists in the wallet, the import is not performed
and error messages are returned.
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "2CiU1CmB6c9jmSLDNBe6PouA7NgNULS"
}
e.g.
Description
Result
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": true
}
e.g.
isEncrypted("2ChqBTvFXttQsghj8zQpcdv76TQU8G5");
Description
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": true
}
{ //Error message
"success": false,
"data" {:
"code": "ACT005",
"msg": "xxxxxx...."
}
}
e.g.
removeAccount("2ChqBTvFXttQsghj8zQpcdv76TQU8G5");
removeAccount("2ChqBTvFXttQsghj8zQpcdv76TQU8G5", "nuls123456");
Description
Set a password for an encrypted account. Unencrypted accounts cannot call this interface
Result
Parameter Type Required Description
newPassword String Yes new password length (8~20). It must include both letters
and numbers, no spaces
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true, //indicate success
"data": {
"value": true
}
}
{ //Error message
"success": false,
"data" {:
"code": "ACT005",
"msg": "xxxxxx...."
}
}
e.g.
Description
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "0020d7a69747778f6f02e2b0171640bc98aa19c53700988b7765c195ae69
1f3202c6"
}
Error Example
{
"success": false,
:
"data" {
"code": "ACT007",
"msg": "The account already set an alias"
}
}
e.g.
Description
Set offline account password, encrypt it independently in SDK, do not interact with NULS
service
(
Result Return encrypted private key encryptedPriKey )
password String Yes New password, password length 8~20, must include both
letters and numbers, no spaces
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
“value”:"a770c1886f566c973b6eb99543ef03825a89ed16e20d8dbe320aed64
a85d5863ca23df43ef16ce0475424a49e192b6f9"
}
}
e.g.
setPasswordOffline("2CacFwqMwcJiGNNBwiwV7bCL7bjwNBr","00e4bfd347351ea899b
5f0ae2c0a3e7a6951b202eaf72432d1a63a2dc85c59c82a","nuls123456");
Description
Set offline account password, encrypt it independently in sdk, do not interact with NULS service
(
Result Return the encrypted private key generated by the new password encryptedPriKey )
Parameter Type Required Introductions
newPassword String Yes New password, password length 8~20, must include
both letters and numbers, no spaces
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
“value”: "7ab9031c634c562c2c742b777b266796414908ad4d9e26231dd353a9d11
3cca246bdd5af25e2547df83fcbe5b386875e"
}
}
e.g.
resetPasswordOffline("2CacFwqMwcJiGNNBwiwV7bCL7bjwNBr","25368dbc0ff7eea4f
c6da22bc37e85d7976a3846f8b58d4dc0cf484e740ba1b61f96395fbe1ddf70ece9fd21fc
d95e7a","NULS111111", "nuls123456");
Result getAccountNumber()
Description
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": 66
}
e.g.
getAccountNumber();
Transaction AccountLedgerService
Description
To create a transaction based on the information of inputDto and outputDto . The sum of
the input amount = the sum of the output + transaction fee, the calculation of the handling fee
will be described in detail below.
e.g.
Description
Sign the transaction by private key
address String Yes the address corresponding to the private key used to verify
the validity of the private key
password String No The password for the private key is not passed if not
encrypted.
e.g.
Description
Result.data TransactionDto
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"hash": "00203a169b42e5e142e20b273ac925e55f773b5a38c5f5c907efdbc4
3abb7d7a67b2",
"type": 2,
"time": 1529323198461,
"blockHeight": 1884,
"fee": 100000,
"value": 99900000000,
"remark": "Transfer",
"scriptSig": "21036dd27c9fa786a1e83df204e9b31ddc24745c378f1f6b427
31d07f05347167c0000473045022100ff3372711d78eb554be331aa40cd7af246641ecd3b
c06f2fdca7faefb25f74e50220743a2f2d9d01b5a77a878349b996cbe4953af5d1a946519
a5ce4d1129cf99848",
"status": 1,
"confirmCount": 14,
"size": 255,
"inputs": [
{
"fromHash": "0020ab020707282932e6ec701f0b64e22e937fdd03ce
9b37aab498aed2e00b6fa8e7",
"fromIndex": 0,
"address": "2ChDcC1nvki521xXhYAUzYXt4RLNULS",
"value": 9999899000000
}
],
"outputs": [
{
"txHash": "00203a169b42e5e142e20b273ac925e55f773b5a38c5f5
c907efdbc43abb7d7a67b2",
"index": 0,
"address": "2CiVA3n1VoNQobAax4d7qNEBZAfehLN",
"value": 99900000000,
"lockTime": 0,
"status": 0
},
{
"txHash": "00203a169b42e5e142e20b273ac925e55f773b5a38c5f5
c907efdbc43abb7d7a67b2",
"index": 1,
"address": "2ChDcC1nvki521xXhYAUzYXt4RLNULS",
"value": 9899998900000,
"lockTime": 0,
"status": 0
}
]
}
}
e.g.
getTxByHash("041f3d2ceed........");
2.4 Transfer
Interface
Description
API Responses
e.g.
//Accounts with password
transfer("2ChDcC1nvki521xXhYAUzYXt4RLNULS", "2CiU1CmB6c9jmSLDNBe6PouA7NgX
XXX", "nuls123456", 8888800000000, "Note:1NULS=10000000Na");
//Accounts without password
transfer("2ChDcC1nvki521xXhYAUzYXt4RLNULS", "2CiU1CmB6c9jmSLDNBe6PouA7NgN
ULS", 8888800000000, "Note:1NULS=10000000Na");
Description
Result.data BalanceDto
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"balance": 1009899998900000,
"usable": 1009899998900000,
"locked": 0
}
}
e.g.
getBalance("2ChDcC1nvki521xXhYAUzYXt4RLNULS");
Description
Broadcast Transaction
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": "002023c66d10cf9047dbcca12aee2235ff9dfe0f13db3c921a2ec22e0dd6
3331cb85"
}
e.g.
BlockService
Description
Get block header information based on block height
Result.data BlockHeaderDto
API Responses
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"hash": "002078656b6e32f4f1e9e881e7b6c4c5de036ae81ec5bf78861bde94
80f5ff3a1b33",
"preHash": "0020ee5d28fde669adb0ad16f3ed426f1ee8df40560bed0ab30bb
99cbf95df276d64",
"merkleHash": "0020cc37658e2d110c1d42f64c7fd3dcb56d9653d4edc4d3a8
406cb263a41f9f5488",
"time": 1529299160000,
"height": 4,
"txCount": 4,
"packingAddress": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"scriptSig": "2102e18d02154e0f68900898efea7ba72d6d14e37d7d173a621
46df2871f40996d7300473045022100d4d92a9518ffd855441c7712f4b31bd003291dc108
fa2b455fe26d51e54625f102202ae8375bd69bf1928f9967edac82619ff78f30550c17797
cc489d5effd3202bf",
"roundIndex": 419517,
"consensusMemberCount": 1,
"roundStartTime": 1529299150000,
"packingIndexOfRound": 1,
"confirmCount": 1909,
"reward": 0,
"fee": 0,
"size": 1
}
}
e.g.
getblockHeader(10);
Description
Result.data BlockHeaderDto
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"hash": "002078656b6e32f4f1e9e881e7b6c4c5de036ae81ec5bf78861bde94
80f5ff3a1b33",
"preHash": "0020ee5d28fde669adb0ad16f3ed426f1ee8df40560bed0ab30bb
99cbf95df276d64",
"merkleHash": "0020cc37658e2d110c1d42f64c7fd3dcb56d9653d4edc4d3a8
406cb263a41f9f5488",
"time": 1529299160000,
"height": 4,
"txCount": 4,
"packingAddress": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"scriptSig": "2102e18d02154e0f68900898efea7ba72d6d14e37d7d173a621
46df2871f40996d7300473045022100d4d92a9518ffd855441c7712f4b31bd003291dc108
fa2b455fe26d51e54625f102202ae8375bd69bf1928f9967edac82619ff78f30550c17797
cc489d5effd3202bf",
"roundIndex": 419517,
"consensusMemberCount": 1,
"roundStartTime": 1529299150000,
"packingIndexOfRound": 1,
"confirmCount": 1909,
"reward": 0,
"fee": 0,
"size": 1
}
}
e.g.
getblockHeader("041f3d2ceed........");
Description
Result.data BlockDto
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"hash": "00209bbcd98110b57f1ecd66c9d94d1a2381e6c03c3b9aa77db25b6e
b5955bb658d3",
"preHash": "00201c0fa53c98595c7f9ba817fca6367aa2da1c1e480f801766b
7a4a16b39c54b67",
"merkleHash": "00200c2dfa0560229ef728cd6bdc858334ef4072d8e25c3b08
31c8366f4d4cb0c168",
"time": 1529323210000,
"height": 1884,
"txCount": 1884,
"packingAddress": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"scriptSig": "2102e18d02154e0f68900898efea7ba72d6d14e37d7d173a621
46df2871f40996d73004730450221009d1015b7cab19ac8099245390ae41ca14da9f47d5c
28b3b7780a53bd8adcccd802202bf74bb764f9de248dfb892d98e9ff91bad25daa107cfdf
4effd3fb1c266e5ae",
"roundIndex": 420416,
"consensusMemberCount": 5,
"roundStartTime": 1529323170000,
"packingIndexOfRound": 4,
"confirmCount": 33,
"reward": 100000,
"fee": 100000,
"size": 5,
"txList": [
{
"hash": "00202b9737b15bf7e4ebc74a58554e461fbed6fedf3e289c
6ef41afa80d83f67babc",
"type": 1,
"time": 1529323210000,
"blockHeight": 1884,
"fee": 0,
"value": 0,
"remark": null,
"scriptSig": null,
"status": 0,
"confirmCount": 33,
"size": 54,
"inputs": [],
"outputs": [
{
"address": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"value": 100000,
"lockTime": 2884
}
]
},
{
"hash": "00203a169b42e5e142e20b273ac925e55f773b5a38c5f5c9
07efdbc43abb7d7a67b2",
"type": 2,
"time": 1529323198461,
"blockHeight": 1884,
"fee": 100000,
"value": 0,
"remark": "Transfer",
"scriptSig": "21036dd27c9fa786a1e83df204e9b31ddc24745c378
f1f6b42731d07f05347167c0000473045022100ff3372711d78eb554be331aa40cd7af246
641ecd3bc06f2fdca7faefb25f74e50220743a2f2d9d01b5a77a878349b996cbe4953af5d
1a946519a5ce4d1129cf99848",
"status": 0,
"confirmCount": 33,
"size": 255,
"inputs": [
{
"fromHash": "0020ab020707282932e6ec701f0b64e22e93
7fdd03ce9b37aab498aed2e00b6fa8e7",
"fromIndex": 0,
"address": null,
"value": 9999899000000
}
],
"outputs": [
{
"address": "2CiVA3n1VoNQobAax4d7qNEBZAfehLN",
"value": 99900000000,
"lockTime": 0
},
{
"address": "2ChDcC1nvki521xXhYAUzYXt4RLNULS",
"value": 9899998900000,
"lockTime": 0
}
]
},
{
"hash": "002040370fcb2ad080abdcd2d91f952826c8f6e55bda7231
c1c15f25d9d74dc8ad7f",
"type": 7,
"time": 1529323210000,
"blockHeight": 1884,
"fee": 0,
"value": 0,
"remark": null,
"scriptSig": null,
"status": 0,
"confirmCount": 33,
"size": 38,
"inputs": [],
"outputs": []
}
]
}
}
e.g.
getBlock(10);
Description
Result.data BlockDto
Parameter Type Required Description
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"hash": "00209bbcd98110b57f1ecd66c9d94d1a2381e6c03c3b9aa77db25b6e
b5955bb658d3",
"preHash": "00201c0fa53c98595c7f9ba817fca6367aa2da1c1e480f801766b
7a4a16b39c54b67",
"merkleHash": "00200c2dfa0560229ef728cd6bdc858334ef4072d8e25c3b08
31c8366f4d4cb0c168",
"time": 1529323210000,
"height": 1884,
"txCount": 1884,
"packingAddress": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"scriptSig": "2102e18d02154e0f68900898efea7ba72d6d14e37d7d173a621
46df2871f40996d73004730450221009d1015b7cab19ac8099245390ae41ca14da9f47d5c
28b3b7780a53bd8adcccd802202bf74bb764f9de248dfb892d98e9ff91bad25daa107cfdf
4effd3fb1c266e5ae",
"roundIndex": 420416,
"consensusMemberCount": 5,
"roundStartTime": 1529323170000,
"packingIndexOfRound": 4,
"confirmCount": 33,
"reward": 100000,
"fee": 100000,
"size": 5,
"txList": [
{
"hash": "00202b9737b15bf7e4ebc74a58554e461fbed6fedf3e289c
6ef41afa80d83f67babc",
"type": 1,
"time": 1529323210000,
"blockHeight": 1884,
"fee": 0,
"value": 0,
"remark": null,
"scriptSig": null,
"status": 0,
"confirmCount": 33,
"size": 54,
"inputs": [],
"outputs": [
{
"address": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"value": 100000,
"lockTime": 2884
}
]
},
{
"hash": "00203a169b42e5e142e20b273ac925e55f773b5a38c5f5c9
07efdbc43abb7d7a67b2",
"type": 2,
"time": 1529323198461,
"blockHeight": 1884,
"fee": 100000,
"value": 0,
"remark": "Transfer",
"scriptSig": "21036dd27c9fa786a1e83df204e9b31ddc24745c378
f1f6b42731d07f05347167c0000473045022100ff3372711d78eb554be331aa40cd7af246
641ecd3bc06f2fdca7faefb25f74e50220743a2f2d9d01b5a77a878349b996cbe4953af5d
1a946519a5ce4d1129cf99848",
"status": 0,
"confirmCount": 33,
"size": 255,
"inputs": [
{
"fromHash": "0020ab020707282932e6ec701f0b64e22e93
7fdd03ce9b37aab498aed2e00b6fa8e7",
"fromIndex": 0,
"address": null,
"value": 9999899000000
}
],
"outputs": [
{
"address": "2CiVA3n1VoNQobAax4d7qNEBZAfehLN",
"value": 99900000000,
"lockTime": 0
},
{
"address": "2ChDcC1nvki521xXhYAUzYXt4RLNULS",
"value": 9899998900000,
"lockTime": 0
}
]
},
{
"hash": "002040370fcb2ad080abdcd2d91f952826c8f6e55bda7231
c1c15f25d9d74dc8ad7f",
"type": 7,
"time": 1529323210000,
"blockHeight": 1884,
"fee": 0,
"value": 0,
"remark": null,
"scriptSig": null,
"status": 0,
"confirmCount": 33,
"size": 38,
"inputs": [],
"outputs": []
}
]
}
}
e.g.
getBlock("041f3d2ceed........");
Description
Result.data BlockHeaderDto
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"hash": "002078656b6e32f4f1e9e881e7b6c4c5de036ae81ec5bf78861bde94
80f5ff3a1b33",
"preHash": "0020ee5d28fde669adb0ad16f3ed426f1ee8df40560bed0ab30bb
99cbf95df276d64",
"merkleHash": "0020cc37658e2d110c1d42f64c7fd3dcb56d9653d4edc4d3a8
406cb263a41f9f5488",
"time": 1529299160000,
"height": 4,
"txCount": 4,
"packingAddress": "2CWsZb9w8XXTE58TUhBGczxf4U6NULS",
"scriptSig": "2102e18d02154e0f68900898efea7ba72d6d14e37d7d173a621
46df2871f40996d7300473045022100d4d92a9518ffd855441c7712f4b31bd003291dc108
fa2b455fe26d51e54625f102202ae8375bd69bf1928f9967edac82619ff78f30550c17797
cc489d5effd3202bf",
"roundIndex": 419517,
"consensusMemberCount": 1,
"roundStartTime": 1529299150000,
"packingIndexOfRound": 1,
"confirmCount": 1909,
"reward": 0,
"fee": 0,
"size": 1
}
}
e.g.
getNewestBlockHash();
Result getNewestBlockHight()
Description
Result.data height(Long)
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"value": 5210
}
}}
e.g.
getNewestBlockHight();
Result getNewestBlockHash()
Desription
Result.data Hash.value(String)
API Response
A successful call to this command will give you a result similar to this (JSON):
{
"success": true,
"data": {
"value": "0020a2e1c99951184700927472c431a5a65847c7974cac0bbb97b24
2c7adf56ad27b"
}
}}
e.g.
getNewestBlockHash();
Appendix
API Response
Result
This is a successful call and return the special date
{
"success": true, //validity of interface execution
"data": Object
}
This is a successful call and returns ture by the functions processing the business
operations
{
"success": true,
"data": {
"value":true
}
}
This is a successful call and returns false by the functions processing the business
operations
{
"success": true,
"data" { :
"value": false
}
}
Error example
{
"success": false,
"data" { :
"code": "ACT005",
"msg": "XXXXXXXX......"
}
}
{
"success": true,
//data List<account>
"data": [
{
"address": "2CacFwqMwcJiGNNBwiwV7bCL7bjwNBr",
"alias": null,
"pubKey": "030d4e752b5aa5d784f19a1fcc73b02afb6f756752fd00ebc2
fcaabc8d0979c4f0",
"extend": null,
"createTime": 1529041525794,
"encrypted": false,
"priKey": "00e4bfd347351ea899b5f0ae2c0a3e7a6951b202eaf72432d1
a63a2dc85c59c82a",
"encryptedPriKey": ""
}
]
}
AccountDto
{
"address": String, Account address
"alias": String, alias
"pubKey": String, public key
"extend": String, extend
"createTime": Long, time of creation
"encrypted": boolean, encrypt
(
"priKey": String, Private key value only if you create an offline acc
ount with no password )
(
"encryptedPriKey": String, encryptedPrivate key value only if you cre
ate an offline account with password )
}
InputDto
{
"fromHash": String, txHash of output source
"fromIndex": Integer, outIndex of output source
"address": String, The address of rolling in
"value": Long The amount of rolling in
}
OutputDto
{
"txHash": String, dealing hash
"index": Integer, Index
"address": String, Address
"value": Long, Amount
"lockTime": Long, The time of locking
"status": Integer 0:usable, 1:timeLock, 2:consensusLock, 3:spent
}
TransactionDto
{
"hash": String, dealing amount of hash
"type": Integer, the types of dealing
"time": Long, the beginning time of dealing
"blockHeight": Long, Block Height
"fee": Long, the cost of dealing
"value": Long, dealing amount
"remark": String, notes
"scriptSig": String, Signature
"status": Integer, States 0:unConfirm, 1:confirm
"confirmCount": Long, confirmation times
"size": int, size
"inputs": [
{
"fromHash": String, txHash of output source
"fromIndex": Integer, outIndex of output source
"address": String, The address of rolling in
"value": Long The amount of rolling in
}
],
"outputs": [
{
"txHash": String, dealing hash
"index": Integer, Index
"address": String, Address
"value": Long, Amount
"lockTime": Long, The time of locking
"status": Integer 0:usable, 1:timeLock, 2:consensusLock, 3:s
pent
}
]
}
BalanceDto
{
"balance": long, Balance
"usable": long, Available BalanceAvailable remainder
locked": long Locked Balance
}
BlockHeaderDto
{
"hash": String, the Hash value of the block
"preHash": String, the preHash value of the block
"merkleHash": String, Merkel hash
"time": Long, The form time of block
"height": Long, Block Height
"txCount": Long, The deal amount of block pack
"packingAddress": String, the address of block pack
"scriptSig": String, Signature
"roundIndex": Long, Common round
"consensusMemberCount": Integer, The amount of member
"roundStartTime": Long, Common round starting time
"packingIndexOfRound": Integer, Packing index of round
"confirmCount": Long, confirmation times
"reward": Long, Rewards
"fee": Long, The handling charge of acquire pack
"size": int, size
}
BlockDto
{
"hash": String, the hash value of the block
"preHash": String, 上一个the hash value of the block
"merkleHash": String, Merkel hash
"time": Long, The form time of block
"height": Long, Block Height
"txCount": Long, The deal amount of block pack
"packingAddress": String, the address of block pack
"scriptSig": String, Signature
"roundIndex": Long, Common round
"consensusMemberCount": Integer, The amount of member
"roundStartTime": Long, Common round starting time
"packingIndexOfRound": Integer, Packing index of round
"confirmCount": Long, confirmation times
"reward": Long, Rewards
"fee": Long, The handling charge of acquire pack
"size": int, size
"txList": [
{
"hash": String, dealing amount of hash
"type": Integer, the types of dealing
"time": Long, the beginning time of dealing
"blockHeight": Long, Block Height
"fee": Long, the cost of dealing
"value": Long, dealing amount
"remark": String, notes
"scriptSig": String, Signature
"status": Integer, States 0:unConfirm, 1:confirm
"confirmCount": Long, confirmation times
"size": int, size
"inputs": [ input
{
"fromHash": String, txHash of output source
"fromIndex": Integer, outIndex of output source
"address": String, The address of rolling in
"value": Long The amount of rolling in
}
],
"outputs": [
{
"address": String, address
"value": Long, Amount
"lockTime": Long, lockTime
}
]
}
]
}
ERROR CODE
("SYS000", "10000") SUCCESS
("SYS001", "10001") FAILED
("SYS006", "10006") DATA_ERROR
("SYS018", "10018") PARAMETER_ERROR
("SYS021", "20021") SIGNATURE_ERROR
("DATA004", "11000") VERIFICATION_FAILD
("DATA001", "11001") DATA_PARSE_ERROR
("ACT000", "50000") PASSWORD_IS_WRONG
("ACT001", "50001") ACCOUNT_NOT_EXIST
("ACT002", "50002")ACCOUNT_IS_ALREADY_ENCRYPTED
("ACT003", "50003")ACCOUNT_EXIST
("ACT004", "50004")ADDRESS_ERROR
("ACT005", "50005") ALIAS_EXIST
("ACT006", "50006")ALIAS_NOT_EXIST
("ACT007", "50007") ACCOUNT_ALREADY_SET_ALIAS
("ACT008", "50008")PARAMETER_ERROR
("ACT009", "50009") DATA_PARSE_ERROR
("ACT010", "50010")SUCCESS
("ACT011", "50011") FAILED
("ACT012", "50012")INSUFFICIENT_BALANCE
("ACT013", "50013") ALIAS_ROLLBACK_ERROR
("ACT014", "50014") ACCOUNTKEYSTORE_FILE_NOT_EXIST
("ACT015", "50015") ACCOUNTKEYSTORE_FILE_DAMAGED
("ACT016", "50016") ALIAS_FORMAT_WRONG
("ACT017", "50017")PASSWORD_FORMAT_WRONG