Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ethernet management APIs

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use ethernet management APIs". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Manage APIs Management APIs

In addition to the official DApp APIs interface, go-ethereun provides additional management API, which uses JSON-RPC and follows the same protocol as DApp API. Geth provides a console client that can access all administrative API.

Open the management APIs

To enable the management API in the Geth RPC terminal, you need to specify the-- ${interface} api parameter on the command line at startup. The values of ${interface} can be the following three:

Rpc: used to open HTTP

Ws: used to open WebSocket

Ipc: used to open unix socket, for Unix systems or named pipe, for Windows systems

For example: geth-ipcapi admin,eth,miner-rpcapi eth,web3-rpc

Enable admin, official DApp and miner API via IPC

Open official DApp and web3 via HTTP

The HTTP RPC interface needs to be explicitly enabled through-- rpc.

Note: through the HTTP and WebSocket interfaces, any user can access these interfaces, so you must be careful when opening those interfaces. By default, Geth provides access to all API through the IPC interface, but only db, eth, net, web3-related API can be accessed through the HTTP and WebSocket interfaces.

To know which API Geth provides, you can call the modules JSON-RPC method, such as the following access via ipc on the unix system:

Echo'{"jsonrpc": "2.0", "method": "rpc_modules", "params": [], "id": 1}'| nc-U $datadir/geth.ipc

This returns all open modules, including the version number:

{"id": 1, "jsonrpc": "2.0"," result ": {" admin ":" 1.0", "db": "1.0"," debug ":" 1.0", "eth": "1.0"," miner ":" 1.0", "net": "1.0"," personal ":" 1.0" "shh": "1. 0", "txpool": "1. 0", "web3": "1. 0"}} use management APIs

These additional management API and official DApp API follow the same protocol. You can extend Web3 and use it to call these additional API.

These different methods can be divided into several logical groups. The following example is implemented through the JavaScript console, but can be easily converted into a RPC request.

For example:

Console: miner.start () IPC: echo'{"jsonrpc", "method": "miner_start", "params": [], "id": 1}'| nc-U $datadir/geth.ipcHTTP: curl-X POST-- data'{"jsonrpc": "method": "miner_start", "param": [], "id": 1} 'localhost:8545

Examples of multithreading:

Console: miner.start (4) IPC: echo'{"jsonrpc", "method": "miner_start", "params": [4], "id": 1}'| nc-U $datadir/geth.ipcHTTP: curl-X POST-- data'{"jsonrpc": "method": "miner_start", "param": [4], "id": 1} 'localhost:8545 manages API list

In addition to the official DApp API namespaces (eth, shh, web3), Geth provides the following administrative API namespaces:

Admin: Geth node (node) management

Debug: Geth node debugging

Miner: mining and DAG management

Personal: account management

Txpool: transaction pool check

Admin:

AddPeer

Datadir

NodeInfo

Peers

SetSolc

StartRPC

StartWS

StopRPC

StopWS

Miner:

SetExtra

SetGasPrice

Start

Stop

GetHashrate

SetEtherbase

Personal:

EcRecover

ImportRawKey

ListAccounts

LockAccount

NewAccount

UnlockAccount

SendTransaction

Sign

Txpool:

Content

Inspect

Status

Debug:

BacktraceAt

BlockProfile

CpuProfile

DumpBlock

GcStats

GetBlockRlp

GoTrace

MemStats

SeedHashsign

SetBlockProfileRate

SetHead

Stacks

StartCPUProfile

StartGoTrace

StopCPUProfile

StopGoTrace

TraceBlock

TraceBlockByNumber

TraceBlockByHash

TraceBlockFromFile

TraceTransaction

Verbosity

Vmodule

WriteBlockProfile

WriteMemProfile

This is the end of the content of "how to use ethernet management APIs". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report