admin
APIs to control Klaytn node.
The namespace admin
gives you access to several non-standard RPC methods. They will allow you to have fine-grained control over your Klaytn instance, including but not limited to network peer and RPC endpoint management.
admin_nodeInfo
The nodeInfo
administrative property can be queried for all the information known about the running Klaytn node at the networking granularity. These include general information about the node itself as a participant of the devp2p P2P overlay protocol, as well as specialized information added by each of the running application protocols, e.g., klay
.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
JSON string | The node information. |
Example
Console
HTTP RPC
admin_datadir
The datadir
administrative property can be queried for the absolute path the running Klaytn node currently uses to store all its databases. The default path is different depending on the node types (kcn, kpn, and ken) and the OS type.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
string | The |
Example
Console
HTTP RPC
admin_peers
The peers
administrative property can be queried for all the information known about the connected remote nodes at the networking granularity. These include general information about the nodes themselves as participants of the devp2p P2P overlay protocol, as well as specialized information added by each of the running application protocols.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
JSON string | The information about all connected peers. |
Example
Console
HTTP RPC
NOTE: All IP addresses below are shown as examples. Please replace them with the actual IP addresses in your execution environment.
admin_addPeer
The addPeer
is an administrative method that requests adding a new remote node to the list of tracked static nodes. 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 kni, which means "Klaytn Network Identifier". It is similar to the enode
concept in the geth. It is URL of the remote peer to start tracking and returns a BOOL
indicating whether the peer was accepted for tracking or some error occurred.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
url | string | Peer's |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_removePeer
The removePeer
is an administrative method that requests removing a node from the list of tracked static nodes.
The method accepts a single argument kni, which means "Klaytn Network Identifier". It is similar to the enode
concept in the geth. It is URL of the remote peer to be removed from a list and returns a BOOL
indicating whether the peer was removed or some error occurred.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
url | string | Peer's |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_startHTTP
NOTE: This API replaces admin_startRPC
. The admin_startRPC
will be deprecated soon.
The startHTTP
is an administrative method that starts an HTTP based JSON RPC API webserver to handle client requests.
The method returns a boolean flag specifying whether the HTTP RPC listener was opened or not. Please note, only one HTTP endpoint is allowed to be active at any time.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
host | string | (optional) network interface to open the listener socket on (default: |
port | int | (optional) network port to open the listener socket on (default: |
cors | string | (optional) cross-origin resource sharing header to use (default: |
apis | string | (optional) API modules to offer over this interface (default: |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_stopHTTP
NOTE: This API replaces admin_stopRPC
. The admin_stopRPC
will be deprecated soon.
The stopHTTP
is an administrative method that closes the currently open HTTP RPC endpoint. As the node can only have a single HTTP endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_startWS
The startWS
is an administrative method that starts an WebSocket based JSON RPC API webserver to handle client requests.
The method returns a boolean flag specifying whether the WebSocket RPC listener was opened or not. Please note, only one WebSocket endpoint is allowed to be active at any time.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
host | string | (optional) network interface to open the listener socket on (default: |
port | int | (optional) network port to open the listener socket on (default: |
cors | string | (optional) cross-origin resource sharing header to use (default: |
apis | string | (optional) API modules to offer over this interface (default: |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_stopWS
The stopWS
is an administrative method that closes the currently open WebSocket RPC endpoint. As the node can only have a single WebSocket endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_exportChain
The exportChain
is an administrative method that exports the blockchain to a file.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
fileName | string | the fully qualified path to the file where the blockchain must be exported. |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_importChain
The importChain
is an administrative method that imports an exported chain from a file into a node. This method imports only blocks that haven't existed in a Klaytn node. This method does not delete any data of the existing chain.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
fileName | string | the fully qualified path to the file containing the chain to be imported. |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_importChainFromString
The importChainFromString
is an administrative method that imports a chain from a RLP-encoded string of blocks into a Klaytn node. This only works if there is no existing chain in a Klaytn node. This method does not delete any data of the existing chain.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
blockRlp | string | the RLP-encoded string that represents the blocks to be imported. (equals to the return value of |
Return Value
Type | Description |
---|---|
bool |
|
Example
Console
HTTP RPC
admin_startStateMigration
The startStateMigration
is an administrative method that starts a state migration and removes old state/storage trie nodes. This can save the storage space of a Klaytn node. The method returns an error if it fails to start a state migration, or null
if it succeeds to start. NOTE: After the state migration, the node cannot serve APIs with previous states.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
Error |
|
Example
Console
HTTP RPC
admin_stopStateMigration
The stopStateMigration
is an administrative method that stops the currently running state migration. This method takes no parameters and returns null
or an error whether the state migration was stopped or not.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
Error |
|
Example
Console
HTTP RPC
admin_stateMigrationStatus
The stateMigrationStatus
is an administrative method that returns the status information of the state migration. This method takes no parameters and returns the status of the currently running state migration.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Name | Type | Description |
---|---|---|
committed | int |
|
err | Error |
|
isMigration | bool |
|
migrationBlockNumber | uint64 | a blockNumber which the state migration started at. ( |
pending | int |
|
progress | float64 |
|
read | int |
|
Example
Console
HTTP RPC
admin_saveTrieNodeCacheToDisk
The saveTrieNodeCacheToDisk
is an administrative method that starts saving the cached trie node to the disk to reuse them when the node restarts. Cached trie node data will be stored to and loaded from $DATA_DIR/fastcache
. This method returns an error if the saving process has been already triggered or trie node cache is disabled. This feature is supported since Klaytn 1.5.3.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
None
Return Value
Type | Description |
---|---|
Error |
|
Example
Console
HTTP RPC
admin_setMaxSubscriptionPerWSConn
The setMaxSubscriptionPerWSConn
is an administrative method that sets the maximum allowed number of subscriptions per single WebSocket connection. For example, if the maximum number is set to five and a user requests more than five subscriptions through the klay_subscribe
API, an error message "Maximum 5 subscriptions are allowed for a WebSocket connection" will be displayed. This feature is supported since Klaytn 1.6.0.
Client | Method invocation |
---|---|
Console |
|
RPC |
|
Parameters
Name | Type | Description |
---|---|---|
limit | int | The maximum allowed number of subscriptions per single WebSocket connection. |
Return Value
Type | Description |
---|---|
Error |
|
Example
Console
HTTP RPC
Last updated