RPC Interface Specification
The Elastos sidechain needs to trade with the mainchain and arbiter, in which the arbiter interacts with the sidechain through JSON-RPC, and the newly added sidechains all need to meet its RPC specification.
The RPC interface that the sidechain must implement is as follows:
getblockcount
description: get block count
parameters: none
argument sample:
1
{
2
"method":"getblockcount"
3
}
Copied!
result sample:
1
{
2
"result": 171454
3
}
Copied!
sendrechargetransaction
description: send recharge to sidechain transaction to transaction pool
argument sample:
1
{
2
"method": "sendtransactioninfo",
3
"params":{
4
"txid":764342ae4a9a60e02a28339b9302871973fd60c25ca79380064dd09dcf14aeb0",
5
}
6
}
Copied!
result sample:
1
{
2
"result":["764342ae4a9a60e02a28339b9302871973fd60c25ca79380064dd09dcf14aeb0"]
3
}
Copied!
If the recharge to the sidechain transaction is double spend, need to return ErrDoubleSpend error
If the recharge to the sidechain transaction is duplicated, need to return ErrMainchainTxDuplicate error
gettransactioninfo
description: get transaction information by hash for check tx3
parameters:
name
type
description
txid
string
the hash of transaction
arguments sample:
1
{
2
"method": "gettransactioninfo",
3
"params": {
4
"txid": "764691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c02"
5
}
6
}
Copied!
result sample:
1
{
2
"result": {
3
"txid":"e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683",
4
"hash":"e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683",
5
"size":282,
6
"vsize":282,
7
"version":0,
8
"locktime":0,
9
"vin":[
10
{
11
"txid":"5228401cca844cc51b255e675cd56bf8b8bce585b19398958829301b617836b6",
12
"vout":0,
13
"sequence":0
14
}
15
],
16
"vout":[
17
{
18
"value":"0.96000000",
19
"n":0,
20
"address":"0000000000000000000000000000000000",
21
"outputlock":0
22
}
23
],
24
"blockhash":"d77a9e0db69dd815f2b5c004852ad7b0b8782ba74aa475f6e1cec203b9ab2bb8",
25
"confirmations":8,
26
"time":1537503765,
27
"blocktime":1537503765,
28
"type":8,
29
"payloadversion":0,
30
"payload":{
31
"crosschainassets":[{
32
"crosschainaddress":"EQSpUzE4XYJhBSx5j7Tf2cteaKdFdixfVB",
33
"outputindex":0,
34
"crosschainamount":95000000
35
}]
36
},
37
"attributes":[{
38
"usage":0,
39
"data":"2d36393130383137303436333135373037373130"
40
}],
41
"programs":[
42
{
43
"code":"21037f3caede72447b6082c1e8f7705ffd1ed6e24f348130d34cbc7c0a35c9e993f5ac",
44
"parameter":"406c9fa867dfb54051ea75932782914fb2212c8c5f3c46b6a27fb50dadf1ca4ee5e699dcf8b7f098745457dc75d3f41f2263dd46a6a06aebdccac8d668d4429ebd"
45
}
46
]
47
}
48
}
Copied!
getwithdrawtransactionbyhash
description: get withdraw transaction by hash; if the transaction exists in the sidechain, need to return the detail information of the withdraw transaction.
Parameters:
name
type
description
Txid
Uint256
the transaction hash
arguments sample:
1
{
2
"method": "getwithdrawtransactionbyhash",
3
"params":{
4
"txid":"b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7"
5
}
6
}
Copied!
result sample:
1
{
2
"result":{
3
"txid":"b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7",
4
"crosschainassets": [
5
"crosschainaddress": "EQSpUzE4XYJhBSx5j7Tf2cteaKdFdixfVB",
6
"crosschainamount": "95000000",
7
"outputamount": "96000000",
8
"targetdata": "",
9
]
10
}
11
}
Copied!
getwithdrawtransactionsbyheight
description: get withdraw transactions by block height
parameters:
name
type
description
height
integer
the height of block chain
arguments sample:
1
{
2
"method": "getwithdrawtransactionsbyheight",
3
"params":{
4
"height":"1"
5
}
6
}
Copied!
result sample:
1
{
2
"result":{
3
"Hash":"b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7",
4
"Height":11193,
5
"Transactions":[
6
{
7
"txid":"e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683",
8
"hash":"e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683",
9
"size":282,
10
"vsize":282,
11
"version":0,
12
"locktime":0,
13
"vin":[
14
{
15
"txid":"5228401cca844cc51b255e675cd56bf8b8bce585b19398958829301b617836b6",
16
"vout":0,
17
"sequence":0
18
}
19
],
20
"vout":[
21
{
22
"value":"0.96000000",
23
"n":0,
24
"address":"0000000000000000000000000000000000",
25
"outputlock":0
26
}
27
],
28
"blockhash":"d77a9e0db69dd815f2b5c004852ad7b0b8782ba74aa475f6e1cec203b9ab2bb8",
29
"confirmations":8,
30
"time":1537503765,
31
"blocktime":1537503765,
32
"type":8,
33
"payloadversion":0,
34
"payload":{
35
"crosschainassets":[{
36
"crosschainaddress":"EQSpUzE4XYJhBSx5j7Tf2cteaKdFdixfVB",
37
"outputindex":0,
38
"crosschainamount":95000000
39
}]
40
},
41
"attributes":[{
42
"usage":0,
43
"data":"2d36393130383137303436333135373037373130"
44
}],
45
"programs":[
46
{
47
"code":"21037f3caede72447b6082c1e8f7705ffd1ed6e24f348130d34cbc7c0a35c9e993f5ac",
48
"parameter":"406c9fa867dfb54051ea75932782914fb2212c8c5f3c46b6a27fb50dadf1ca4ee5e699dcf8b7f098745457dc75d3f41f2263dd46a6a06aebdccac8d668d4429ebd"
49
}
50
]
51
}
52
]
53
}
54
}
Copied!
getfaileddeposittransactionbyhash
description: get failed deposit withdraw transaction by hash; if the transaction exists in the sidechain, need to return the same hash directly.
Parameters:
name
type
description
Txid
Uint256
the transaction hash
arguments sample:
1
{
2
"method": "getfaileddeposittransactionbyhash",
3
"params":{
4
"hash":"b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7"
5
}
6
}
Copied!
result sample:
1
{
2
"result": "b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7",
3
}
Copied!
getexistdeposittransactions
description: check deposit transactions and return existed transactions
parameters:
name
type
description
txs
[]string
hashes of deposit transactions
arguments sample:
1
{
2
"method": "getexistdeposittransactions",
3
"params": {
4
"txs": [
5
"164691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c01",
6
"264691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c02",
7
"364691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c03"
8
]
9
}
10
}
Copied!
result sample:
1
{
2
"result":{
3
"txs": [
4
"264691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c02",
5
"364691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c03"
6
]
7
}
8
}
Copied!

RPC Error

The structure of the error is as follows if it's found and returned:
1
{
2
"error": {
3
"code": error code,
4
"message": error message,
5
}
6
}
Copied!
Copy link
Contents
RPC Error