The namespace subbridge
provides functions related to Service Chain. To use the functions in this namespace, the option subbridge
should be enabled in the SEN connected to the service chain.
subbridge_nodeInfo
Returns bridge node information including the KNI (Klaytn Network Identifier) of the node. A subbridge node can connect to a mainbridge node via the KNI.
Parameters
None
Return Value
Example
Copy > subbridge .nodeInfo
{
kni: "kni://f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726@[::]:50505?discport=0",
id: "f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726",
ip : "::" ,
listenAddr : "[::]:50505" ,
name : "-2" ,
ports : {
discovery : 0 ,
listener : 50505
} ,
protocols : {
servicechain : {
config : {
chainId : 2018 ,
deriveShaImpl : 0 ,
isBFT : true ,
istanbul : { ... } ,
unitPrice : 0
} ,
difficulty : 87860 ,
genesis : "0x711ce9865492659977abb2758d29f68c2b0c82862d9376f25953579f64f95b58" ,
head : "0x0d4b130731f1e7560e4531ac73d55ac8c6daccb178abd86af0d96b7aafded7c5" ,
network : 1
}
}
}
subbridge_addPeer
Returns true
if adding a mainbridge peer is done successfully.
The addPeer
method adds a new remote node to the peer list. The node will try to maintain connectivity to these nodes at all times, reconnecting every once in a while if the remote connection goes down.
The method accepts a single argument, the kni
URL of the remote peer to start tracking and returns a BOOL
indicating whether the peer was accepted for tracking or some error occurred.
Parameters
Return Value
Example
Console
Copy > mainbridge .addPeer ( "kni://a979fb...1163c@10.0.0.1:50505" ) // or 'subbridge.addPeer'
true
HTTP RPC
Copy $ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_addPeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net
{ "jsonrpc" : "2.0" , "id" :1, "result" :true}
subbridge_removePeer
Returns true
if removing the peer is done successfully.
The removePeer
method disconnects and removes the remote node in the list of tracked static nodes. The method accepts a single argument, the kni
URL of the remote peer to start tracking and returns a BOOL
indicating whether the peer was accepted for tracking or some error occurred.
Parameters
Return Value
Example
Console
Copy > mainbridge .removePeer ( "kni://a979fb...1163c@10.0.0.1:50505" ) // or 'subbridge.removePeer'
true
HTTP RPC
Copy $ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_removePeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net
{ "jsonrpc" : "2.0" , "id" :1, "result" :true}
subbridge_parentOperator
The subbridge_parentOperator
returns the parent operator account address.
Parameters
none
Return Value
Example
Copy > subbridge .parentOperator
"0xA057995175B93Ee0D1bdfA54f078Ad0F0116130b"
subbridge_childOperator
The subbridge_childOperator
returns the child operator account address.
Parameters
none
Return Value
Example
Copy > subbridge .childOperator
"0x5C1C757a6Cb6c6FcEFE398674D8209FDA2A74Df4"
subbridge_parentOperatorNonce
The subbridge_parentOperatorNonce
returns the nonce of the parent operator account address.
Parameters
none
Return Value
Example
Copy > subbridge .parentOperatorNonce
1348
subbridge_childOperatorNonce
The subbridge_childOperator
returns the child operator account address.
Parameters
none
Return Value
Example
Copy > subbridge .childOperatorNonce
1024
subbridge_parentOperatorBalance
The subbridge_parentOperatorBalance
returns the balance of the parent operator account.
Parameters
none
Return Value
Example
Copy > subbridge .parentOperatorBalance
1e+50
subbridge_childOperatorBalance
The subbridge_childOperatorBalance
returns the balance of the child operator account.
Parameters
none
Return Value
Example
Copy > subbridge .childOperatorBalance
1e+50
subbridge_sendChainTxslimit
The sendChainTxslimit
gets the maximum number of pending transactions to pick up for sending at once.
Parameters
None
Return Value
Example
Copy > subbridge .sendChainTxslimit
100
subbridge_anchoring
The subbridge_anchoring
can enable/disable the anchoring feature of the service chain.
Parameters
Return Value
Example
Console
Copy > subbridge .anchoring ( true )
true
> subbridge .anchoring ( false )
false
HTTP RPC
Copy $ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"subbridge_anchoring","params":[true],"id":1}' https://public-en-baobab.klaytn.net
{ "jsonrpc" : "2.0" , "id" :1, "result" :true}
$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"subbridge_anchoring","params":[false],"id":1}' https://public-en-baobab.klaytn.net
{ "jsonrpc" : "2.0" , "id" :1, "result" :false}
subbridge_latestAnchoredBlockNumber
The subbridge_latestAnchoredBlockNumber
returns the latest anchored block number of the service chain.
Parameters
None
Return Value
Example
Copy > subbridge .latestAnchoredBlockNumber
71025
subbridge_getReceiptFromParentChain
The subbridge_getReceiptFromParentChain
returns the receipt of the anchoring transaction.
Parameters
Return Value
Object
- A transaction receipt object, or null
when no receipt was found.
Example
Copy > subbridge .getReceiptFromParentChain ( "0x4f300d6574e71d7940c88fe08f27d9ac45cbc7b81d45c17e848d3772f64377b5" )
{
contractAddress : "0x0000000000000000000000000000000000000000" ,
gasUsed : "0x9470" ,
logs : [] ,
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
status : "0x1" ,
transactionHash : "0x3641f52359f44ef2a9941ea840aed4befbace5cac28d5cc8cacd94eae211fd1e"
}
subbridge_deployBridge
The subbridge_deployBridge
deploys a bridge contract to the parent and child chains and returns the addresses of deployed bridge contracts. This method also registers the bridge contracts with the sub-bridge.
Parameters
none
Return Value
Example
Copy > subbridge .deployBridge ()
[ "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a" , "0x23dab942822021bbd6d551ef51003208924877e4" ]
subbridge_registerBridge
The subbridge_registerBridge
registers already deployed bridge contracts in the parent and child chains.
Parameters
Return Value
Example
Copy > subbridge .registerBridge ( "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a" , "0x23dab942822021bbd6d551ef51003208924877e4" )
null
> subbridge .registerBridge ( "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a" , "0x23dab942822021bbd6d551ef51003208924877e4" )
Error : bridge already exists
subbridge_deregisterBridge
The subbridge.deregisterBridge
deregisters already registered bridge contracts in the parent/child chain.
Parameters
Return Value
Example
Copy > subbridge.deregisterBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4")
null
> subbridge.deregisterBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4")
Error : invalid bridge pair
subbridge_subscribeBridge
The subbridge_subscribeBridge
subscribes to the registered bridge contracts in the parent and child chains. If the sub-bridge node is subscribed to the bridge contract pair, cross-chain value-transfer requests are handled automatically by the sub-bridge.
Parameters
Return Value
Example
Copy > subbridge .subscribeBridge ( "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a" , "0x23dab942822021bbd6d551ef51003208924877e4" )
null
> subbridge .subscribeBridge ( "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a" , "0x23dab942822021bbd6d551ef51003208924877e4" )
Error : already subscribed
subbridge_unsubscribeBridge
The subbridge_unsubscribeBridge
unsubscribes the sub-bridge from the bridge contracts in the parent and child chains. If the sub-bridge is unsubscribed from the bridge contracts, cross-chain value transfer requests can not be handled by the sub-bridge.
Parameters
Return Value
Example
Copy > subbridge.unsubscribeBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4")
null
subbridge_registerToken
The subbridge_registerToken
registers a pair of ERC-20 or 721 tokens with the bridge contracts.
Parameters
Return Value
Example
Copy > subbridge.registerToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec")
null
> subbridge.registerToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec")
Error : token already exists
subbridge_deregisterToken
The subbridge_deregisterBridge
deregisters already registered token pair from the bridge contracts.
Parameters
Return Value
Example
Copy > subbridge.deregisterToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec")
null
> subbridge.deregisterToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec")
Error : invalid token pair
subbridge_convertRequestTxHashToHandleTxHash
The subbridge_convertRequestTxHashToHandleTxHash
returns the corresponding "handle value transfer transaction" hash in the opposite chain for the given "request value transfer transaction" hash. "Request value transfer transaction" is a transaction initiated by a user, requesting a cross-chain value transfer. "Handle value transfer transaction" is the transaction created by the sub-bridge to handle the value transfer request from the user.
Parameters
Return Value
Example
Copy > subbridge .convertRequestTxHashToHandleTxHash ( "0xae5604f8673098436ee4eaf1b453f1a395afccd6e8eb674c60edd63ebb047622" )
"0x97493d1a91d65c149763209be6535efdacf8f1b50c99daa22abf06502010b2ee"
> subbridge .convertRequestTxHashToHandleTxHash ( "0xc585cfd1e7047b4faae69e62e77db192d8a339701b40d6ab4adb58453b934bec" )
"0x0000000000000000000000000000000000000000000000000000000000000000"
subbridge_listBridge
The subbridge_listBridge
returns the list of all bridge contract pairs that are registered (stored) in the sub-bridge.
Parameters
nonce
Return Value
Example
Copy > subbridge .listBridge
[{
localAddress : "0x27caeba831d98b5fbb1d81ce0ed20801702f443a" ,
remoteAddress : "0x22c41ae528627b790233d2e59ea520be12350eb5" ,
subscribed : true
} , {
localAddress : "0x376b72abe1b29cace831bd3f5acdfa967814c9cd" ,
remoteAddress : "0x53160735f7cc6ff75e48619f368bb94daff66a1b" ,
subscribed : false
} , {
localAddress : "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a" ,
remoteAddress : "0x23dab942822021bbd6d551ef51003208924877e4" ,
subscribed : false
}]
subbridge_getBridgeInformation
The subbridge_getBridgeInformation
returns the information of the given bridge contract.
Parameters
Return Value
Example
Copy > subbridge .getBridgeInformation ( "0x27caeba831d98b5fbb1d81ce0ed20801702f443a" )
{
counterPart : "0x0000000000000000000000000000000000000000" ,
handleNonce : 0 ,
lowerHandleNonce : 0 ,
isRunning : true ,
isSubscribed : true ,
onServiceChain : true ,
pendingEventSize : 0 ,
requestNonce : 0
}
subbridge_txPendingCount
The subbridge_txPendingCount
returns the number of pending transactions in the bridge transaction pool.
Parameters
None
Return Value
Example
Copy > subbridge .txPendingCount
2
subbridge_txPending
The subbridge_txPending
returns the list of pending transactions in the bridge transaction pool.
Parameters
None
Return Value
Example
Copy > subbridge .txPending
{
0xa057995175b93ee0d1bdfa54f078ad0f0116130b : [{
from : "0xa057995175b93ee0d1bdfa54f078ad0f0116130b" ,
gas : "0x186a0" ,
gasPrice : "0x5d21dba00" ,
hash : "0x284c8f5bc82ef987c3a14fc8dac7933beb528777745987ff790014441f26ca03" ,
input: "0xf8a9a063f41a6ec8e2f8074c30fccf11f2b8479e7ebd8a0e5aa0c171623bc1f3812e33a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0f845557d8dc2175974f29c2e9d12b1a57f634acaafdf56ae7033201a0796bedea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a09109530b191b47ca3d91012faba70fcf307f13b030f19d932cab38f2c1ece7b78304157c",
nonce : "0x41589" ,
signatures : [{ ... }] ,
type : "TxTypeChainDataAnchoring" ,
typeInt : 72
} , {
from : "0xa057995175b93ee0d1bdfa54f078ad0f0116130b" ,
gas : "0x186a0" ,
gasPrice : "0x5d21dba00" ,
hash : "0x4dd093916a419608091da28b5d7ffc6e34d894ddaac96328f1904bfef93a4ad0" ,
input: "0xf8a9a05b0dd6cc938916e37b17b602690399987b4e8540a14a494626d85e947f721a10a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a063f41a6ec8e2f8074c30fccf11f2b8479e7ebd8a0e5aa0c171623bc1f3812e33a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a09109530b191b47ca3d91012faba70fcf307f13b030f19d932cab38f2c1ece7b78304157d",
nonce : "0x4158a" ,
signatures : [{ ... }] ,
type : "TxTypeChainDataAnchoring" ,
typeInt : 72
}]
}