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:
Copy {
"method" : "getblockcount"
}
result sample:
sendrechargetransaction
description: send recharge to sidechain transaction to transaction pool
argument sample:
Copy {
"method" : "sendtransactioninfo" ,
"params" : {
"txid" : 764342 ae 4 a 9 a 60e02 a 28339 b 9302871973 fd 60 c 25 ca 79380064 dd 09 dcf 14 aeb 0 ",
}
}
result sample:
Copy {
"result" : [ "764342ae4a9a60e02a28339b9302871973fd60c25ca79380064dd09dcf14aeb0" ]
}
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:
arguments sample:
Copy {
"method" : "gettransactioninfo" ,
"params" : {
"txid" : "764691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c02"
}
}
result sample:
Copy {
"result" : {
"txid" : "e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683" ,
"hash" : "e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683" ,
"size" : 282 ,
"vsize" : 282 ,
"version" : 0 ,
"locktime" : 0 ,
"vin" : [
{
"txid" : "5228401cca844cc51b255e675cd56bf8b8bce585b19398958829301b617836b6" ,
"vout" : 0 ,
"sequence" : 0
}
] ,
"vout" : [
{
"value" : "0.96000000" ,
"n" : 0 ,
"address" : "0000000000000000000000000000000000" ,
"outputlock" : 0
}
] ,
"blockhash" : "d77a9e0db69dd815f2b5c004852ad7b0b8782ba74aa475f6e1cec203b9ab2bb8" ,
"confirmations" : 8 ,
"time" : 1537503765 ,
"blocktime" : 1537503765 ,
"type" : 8 ,
"payloadversion" : 0 ,
"payload" : {
"crosschainassets" : [{
"crosschainaddress" : "EQSpUzE4XYJhBSx5j7Tf2cteaKdFdixfVB" ,
"outputindex" : 0 ,
"crosschainamount" : 95000000
}]
} ,
"attributes" : [{
"usage" : 0 ,
"data" : "2d36393130383137303436333135373037373130"
}] ,
"programs" : [
{
"code" : "21037f3caede72447b6082c1e8f7705ffd1ed6e24f348130d34cbc7c0a35c9e993f5ac" ,
"parameter" : "406c9fa867dfb54051ea75932782914fb2212c8c5f3c46b6a27fb50dadf1ca4ee5e699dcf8b7f098745457dc75d3f41f2263dd46a6a06aebdccac8d668d4429ebd"
}
]
}
}
getwithdrawtransactionbyhash
description: get withdraw transaction by hash; if the transaction exists in the sidechain, need to return the detailed information of the withdraw transaction.
Parameters:
arguments sample:
Copy {
"method" : "getwithdrawtransactionbyhash" ,
"params" : {
"txid" : "b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7"
}
}
result sample:
Copy {
"result" : {
"txid" : "b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7" ,
"crosschainassets" : [
"crosschainaddress" : "EQSpUzE4XYJhBSx5j7Tf2cteaKdFdixfVB" ,
"crosschainamount" : "95000000" ,
"outputamount" : "96000000" ,
"targetdata" : "" ,
]
}
}
getwithdrawtransactionsbyheight
description: get withdraw transactions by block height
parameters:
the height of block chain
arguments sample:
Copy {
"method" : "getwithdrawtransactionsbyheight" ,
"params" : {
"height" : "1"
}
}
result sample:
Copy {
"result" : {
"Hash" : "b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7" ,
"Height" : 11193 ,
"Transactions" : [
{
"txid" : "e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683" ,
"hash" : "e30e315681fc104820737baa41e65eb0668d979f81c4169708f72801a0046683" ,
"size" : 282 ,
"vsize" : 282 ,
"version" : 0 ,
"locktime" : 0 ,
"vin" : [
{
"txid" : "5228401cca844cc51b255e675cd56bf8b8bce585b19398958829301b617836b6" ,
"vout" : 0 ,
"sequence" : 0
}
] ,
"vout" : [
{
"value" : "0.96000000" ,
"n" : 0 ,
"address" : "0000000000000000000000000000000000" ,
"outputlock" : 0
}
] ,
"blockhash" : "d77a9e0db69dd815f2b5c004852ad7b0b8782ba74aa475f6e1cec203b9ab2bb8" ,
"confirmations" : 8 ,
"time" : 1537503765 ,
"blocktime" : 1537503765 ,
"type" : 8 ,
"payloadversion" : 0 ,
"payload" : {
"crosschainassets" : [{
"crosschainaddress" : "EQSpUzE4XYJhBSx5j7Tf2cteaKdFdixfVB" ,
"outputindex" : 0 ,
"crosschainamount" : 95000000
}]
} ,
"attributes" : [{
"usage" : 0 ,
"data" : "2d36393130383137303436333135373037373130"
}] ,
"programs" : [
{
"code" : "21037f3caede72447b6082c1e8f7705ffd1ed6e24f348130d34cbc7c0a35c9e993f5ac" ,
"parameter" : "406c9fa867dfb54051ea75932782914fb2212c8c5f3c46b6a27fb50dadf1ca4ee5e699dcf8b7f098745457dc75d3f41f2263dd46a6a06aebdccac8d668d4429ebd"
}
]
}
]
}
}
getfaileddeposittransactionbyhash
description: get failed deposit withdraw transaction by hash; if the transaction exists in the sidechain, need to return the same hash directly.
Parameters:
arguments sample:
Copy {
"method" : "getfaileddeposittransactionbyhash" ,
"params" : {
"hash" : "b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7"
}
}
result sample:
Copy {
"result" : "b82babb903c2cee1f675a44aa72b78b8b0d72a8504c0b5f215d89db60d9e7ad7" ,
}
getexistdeposittransactions
description: check deposit transactions and return existed transactions
parameters:
hashes of deposit transactions
arguments sample:
Copy {
"method" : "getexistdeposittransactions" ,
"params" : {
"txs" : [
"164691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c01" ,
"264691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c02" ,
"364691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c03"
]
}
}
result sample:
Copy {
"result" : {
"txs" : [
"264691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c02" ,
"364691821f937fd566bcf533611a5e5b193008ea1ba1396f67b7b0da22717c03"
]
}
}
RPC Error
The structure of the error is as follows if it's found and returned:
Copy {
"error" : {
"code" : error code ,
"message" : error message ,
}
}