본문으로 건너뛰기
This page uses machine translation from English, which may contain errors or unclear language. For the most accurate information, please see the original English version. Some content may be in the original English due to frequent updates. Help us improve this page's translation by joining our effort on Crowdin. (Crowdin translation page, Contributing guide)

caver.rpc.net

caver.rpc.net provides JSON-RPC call with net name space.

caver.rpc.net.getNetworkId


caver.rpc.net.getNetworkId([callback])

Returns the network identifier (network ID) of the kaia Node.

Parameters

NameTypeDescription
callbackfunction(optional) Optional callback, returns an error object as the first parameter and the result as the second.

Return Value

Promise returns number

TypeDescription
numberThe network id.

Example


> caver.rpc.net.getNetworkId().then(console.log)
1001

caver.rpc.net.isListening


caver.rpc.net.isListening([callback])

Returns true if the kaia Node is actively listening for network connections.

Parameters

NameTypeDescription
callbackfunction(optional) Optional callback, returns an error object as the first parameter and the result as the second.

Return Value

Promise returns boolean

TypeDescription
booleantrue when listening, otherwise false.

Example


> caver.rpc.net.isListening().then(console.log)
true

caver.rpc.net.getPeerCount


caver.rpc.net.getPeerCount([callback])

Returns the number of peers currently connected to the kaia Node.

Parameters

NameTypeDescription
callbackfunction(optional) Optional callback, returns an error object as the first parameter and the result as the second.

Return Value

Promise returns string

TypeDescription
stringThe number of connected peers in hex.

Example


> caver.rpc.net.getPeerCount().then(console.log)
0x3

caver.rpc.net.getPeerCountByType


caver.rpc.net.getPeerCountByType([callback])

Returns the number of connected nodes by type and the total number of connected nodes with key/value pairs.

Parameters

NameTypeDescription
callbackfunction(optional) Optional callback, returns an error object as the first parameter and the result as the second.

Return Value

Promise returns object

TypeDescription
objectThe number of connected peers by type as well as the total number of connected peers.

Example


> caver.rpc.net.getPeerCountByType().then(console.log)
{ en: 1, pn: 2, total: 3 }

페이지를 개선해 주세요