ADMIN methods
The ADMIN API methods provide administrative functionality to manage your node.
The ADMIN API is not enabled by default for JSON-RPC.
Enable it using the --rpc-http-api or --rpc-ws-api option.
admin_addPeer
Adds a static node.
If connections are timing out, ensure the node ID in the enode URL is correct.
Parameters
enode: string - Enode URL of peer to add.
Returns
trueif peer added orfalseif peer is already a static node.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_addPeer",
"params": [
"enode://f59c0ab603377b6ec88b89d5bb41b98fc385030ab1e4b03752db6f7dab364559d92c757c13116ae6408d2d33f0138e7812eb8b696b2a22fe3332c4b5127b22a3@127.0.0.1:30304"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_addPeer",
"params": [
"enode://f59c0ab603377b6ec88b89d5bb41b98fc385030ab1e4b03752db6f7dab364559d92c757c13116ae6408d2d33f0138e7812eb8b696b2a22fe3332c4b5127b22a3@127.0.0.1:30304"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
admin_changeLogLevel
Changes the log level without restarting Besu. You can change the log level for all logs, or you can change the log level for specific packages or classes.
You can specify only one log level per RPC call.
Parameters
-
level: string - Log level. -
log_filter: array - (Optional) Packages or classes for which to change the log level.
Returns
Successif the log level has changed, otherwiseerror.
Example
The following example changes the debug level for specified classes to DEBUG.
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_changeLogLevel",
"params": [
"DEBUG",
[
"org.hyperledger.besu.ethereum.eth.manager",
"org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.ApiHandler"
]
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_changeLogLevel",
"params": [
"DEBUG",
[
"org.hyperledger.besu.ethereum.eth.manager",
"org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.ApiHandler"
]
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "Success"
}
The following example changes the debug level of all logs to WARN.
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_changeLogLevel",
"params": [
"WARN"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_changeLogLevel",
"params": [
"WARN"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "Success"
}
admin_generateLogBloomCache
Generates cached log bloom indexes for blocks.
API methods such as eth_getLogs and eth_getFilterLogs use the cache for improved performance.
Manually executing admin_generateLogBloomCache is not required unless the --auto-log-bloom-caching-enabled command line option is set to false.
Each index file contains 100000 blocks. The last fragment of blocks less than 100000 are not indexed.
Parameters
-
startBlock: string - Block to start generating indexes. -
endBlock: string - Block to stop generating indexes.
Returns
-
Log bloom index details.
-
startBlock: string - Starting block for the last requested cache generation. -
endBlock: string - Ending block for the last requested cache generation. -
currentBlock: string - Most recent block added to the cache. -
indexing: boolean - Indicates if indexing is in progress. -
requestAccepted: boolean - Indicates acceptance of the request from this call to generate the cache.
-
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_generateLogBloomCache",
"params": [
"0x0",
"0x10000"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_generateLogBloomCache",
"params": [
"0x0",
"0x10000"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"startBlock": "0x0",
"endBlock": "0x10000",
"currentBlock": "0x0",
"indexing": true,
"requestAccepted": true
}
}
admin_logsRemoveCache
Removes cache files for the specified range of blocks.
Parameters
-
fromBlock: string - Hexadecimal integer representing a block number, or one of the string tagslatest,earliest,pending,finalized, orsafe, as described in block parameter. -
toBlock: string - Hexadecimal integer representing a block number, or one of the string tagslatest,earliest,pending,finalized, orsafe, as described in block parameter.
pending returns the same value as latest.
You can skip a parameter by using an empty string, "". If you specify:
- No parameters, the call removes cache files for all blocks.
- Only
fromBlock, the call removes cache files for the specified block. - Only
toBlock, the call removes cache files from the genesis block to the specified block.
Returns
Cache Removedstatus orerror.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_logsRemoveCache",
"params": [
"0x1",
"0x64"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_logsRemoveCache",
"params": [
"0x1",
"0x64"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"Status": "Cache Removed"
}
}
admin_logsRepairCache
Repairs cached logs by fixing all segments starting with the specified block number.
Parameters
startBlock: string - Decimal index of the starting block to fix. The default is the head block.
Returns
- Status of the repair request;
StartedorAlready running.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_logsRepairCache",
"params": [
"1200"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_logsRepairCache",
"params": [
"1200"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"Status": "Started"
}
}
admin_nodeInfo
Returns networking information about the node. The information includes general information about the node and specific information from each running Ethereum sub-protocol (for example, eth).
Parameters
- None
Returns
-
Node object.
-
id: string - Node public key. -
name: string - Client name. -
activeFork: string - Active EVM hard fork name for the current chain head. -
enode: string - Enode URL of the node. -
enr: string - ENR URL of the node. -
ip: string - IP address. -
ipv6: string - IPv6 address. -
listenAddr: string - Host and port for the node. -
listenAddrV6: string - IPv6 host and port for the node. -
ports: object - Peer discovery and listening ports.-
discovery: number - UDP discovery port. -
discoveryV6: number - IPv6 UDP discovery port. -
listener: number - TCP listening port. -
listenerV6: number - IPv6 TCP listening port.
-
-
protocols: object - List of objects containing information for each Ethereum sub-protocol.
noteIf the node is running locally, the host of the
enodeandlistenAddrdisplay as[::]in the result. When advertising externally, the external address displayed for theenodeandlistenAddris defined by--nat-method. -
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_nodeInfo",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_nodeInfo",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"id": "bdf43211dba30bf100a00040b9f839e17161c88c8573028b8533c8adf8ed1e9466e4b87d716d06292426d154d0df7acde83c3f68df151da5413224b22f049054",
"name": "besu/v26.3-develop-f2ec0fe/osx-aarch_64/oracle_openjdk-java-22",
"enode": "enode://87ec35d558352cc55cd1bf6a472557797f91287b78fe5e86760219124563450ad1bb807e4cc61e86c574189a851733227155551a14b9d0e1f62c5e11332a18a3@[::]:30303",
"enr": "enr:-Jq4QOBEJ_aqkcth60IN44olOQ3uNsfqwEahYc6eKRfBg8ZlGbqhHTKqN_Yr67QWUA9v8_l-iaYhpd2uJC_AEQDv3agCg2V0aMrJhPxk7ASDEYwwgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQK99DIR26ML8QCgAEC5-DnhcWHIjIVzAouFM8it-O0elIN0Y3CCdl-DdWRwgnZf",
"ip": "172.28.0.10",
"ipv6": "fd00:dead:beef:0:0:0:0:10",
"listenAddr": "172.28.0.10:30303",
"listenAddrV6": "[fd00:dead:beef:0:0:0:0:10]:30404",
"ports": {
"discovery": 30303,
"discoveryV6": 30404,
"listener": 30303,
"listenerV6": 30404
},
"protocols": {
"eth": {
"config": {
"chainId": 2018,
"homesteadBlock": 0,
"daoForkBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"constantinopleFixBlock": 0,
"ethash": {
"fixeddifficulty": 100
}
},
"difficulty": 78536,
"genesis": "0x43ee12d45470e57c86a0dfe008a5b847af9e372d05e8ba8f01434526eb2bea0f",
"head": "0xc6677651f16d07ae59cab3a5e1f0b814ed2ec27c00a93297b2aa2e29707844d9",
"network": 2018
}
}
}
}
admin_peers
Returns networking information about connected remote nodes.
Parameters
- None
Returns
-
List of objects returned for each remote node.
-
version: string - P2P protocol version. -
name: string - Client name. -
caps: array of strings - List of Ethereum sub-protocol capabilities. -
network: object - Local and remote addresses established at time of bonding with the peer (the remote address might not match the hex value forport; it depends on which node initiated the connection.) -
port: string - Port on the remote node on which P2P discovery is listening. -
id: string - Node public key (excluding the0xprefix, the node public key is the ID in the enode URLenode://<id ex 0x>@<host>:<port>.) -
protocols: object - Current state of peer includingdifficulty,head, andlatestBlock(headis the hash of the highest known block for the peer;latestBlockis the corresponding block number.) -
enode: string - Enode URL of the remote node.
-
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_peers",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_peers",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"version": "0x5",
"name": "besu/v20.10.4-dev-0905d1b2/osx-x86_64/adoptopenjdk-java-11",
"caps": ["eth/67", "eth/68", "IBF/1"],
"network": {
"localAddress": "192.168.1.229:50115",
"remoteAddress": "168.61.153.255:40303"
},
"port": "0x765f",
"id": "0xe143eadaf670d49afa3327cae2e655b083f5a89dac037c9af065914a9f8e6bceebcfe7ae2258bd22a9cd18b6a6de07b9790e71de49b78afa456e401bd2fb22fc",
"protocols": {
"eth": {
"difficulty": "0x1ac",
"head": "0x964090ae9277aef43f47f1b8c28411f162243d523118605f0b1231dbfdf3611a",
"latestBlock": 428,
"version": 65
}
},
"enode": "enode://e143eadaf670d49afa3327cae2e655b083f5a89dac037c9af065914a9f8e6bceebcfe7ae2258bd22a9cd18b6a6de07b9790e71de49b78afa456e401bd2fb22fc@127.0.0.1:30303"
}
]
}
admin_removePeer
Removes a static node.
Parameters
enode: string - Enode URL of peer to remove.
Returns
trueif peer removed orfalseif peer is not a static node.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "admin_removePeer",
"params": [
"enode://f59c0ab603377b6ec88b89d5bb41b98fc385030ab1e4b03752db6f7dab364559d92c757c13116ae6408d2d33f0138e7812eb8b696b2a22fe3332c4b5127b22a3@127.0.0.1:30304"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "admin_removePeer",
"params": [
"enode://f59c0ab603377b6ec88b89d5bb41b98fc385030ab1e4b03752db6f7dab364559d92c757c13116ae6408d2d33f0138e7812eb8b696b2a22fe3332c4b5127b22a3@127.0.0.1:30304"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}