Introduction
JSON-RPC is provided on multiple transports. The Parallax client supports JSON-RPC over HTTP, WebSocket and Unix Domain Sockets. Transports must be enabled through command-line flags. The Parallax JSON-RPC APIs use a name-space system. RPC methods are grouped into several categories depending on their purpose. All method names are composed of the namespace, an underscore, and the actual method name within the namespace. For example, theeth_call
method resides in the eth
namespace.
Access to RPC methods can be enabled on a per-namespace basis. Find documentation for individual namespaces in the sidebar.
Transports
There are three transport protocols available in the Parallax client: IPC, HTTP and Websockets.HTTP Server
HTTP is a unidirectional transport protocol that connects a client and server. The client sends a request to the server, and the server returns a response back to the client. An HTTP connection is closed after the response for a given request is sent. HTTP is supported in every browser as well as almost all programming toolchains. Due to its ubiquity it has become the most widely used transport for interacting with the Parallax client. To start a HTTP server in Parallax client, include the--http
flag:
--http.addr
and --http.port
flags:
eth
, net
and web3
namespaces. To enable access to other APIs like debugging (debug
), they must be configured using the --http.api
flag. Enabling these APIs over HTTP is not recommended because access to these methods increases the attack surface.
--http.corsdomain
flag.
--http.corsdomain
command also accepts wildcards that enable access to the RPC from any origin:
WebSocket Server
Websocket is a bidirectional transport protocol. A Websocket connection is maintained by client and server until it is explicitly terminated by one. Most modern browsers support Websocket which means it has good tooling. Because Websocket is bidirectional, servers can push events to clients. That makes Websocket a good choice for use-cases involving event subscription. Another benefit of Websocket is that after the handshake procedure, the overhead of individual messages is low, making it good for sending high number of requests. Configuration of the WebSocket endpoint in the Parallax client follows the same pattern as the HTTP transport. WebSocket access can be enabled using the--ws
flag. If no additional information is provided, the Parallax client falls back to its default behaviour which is to establish the Websocket on port 8546
. The --ws.addr
, --ws.port
and --ws.api
flags can be used to customize settings for the WebSocket server. For example, to start the Parallax client with a Websocket connection for RPC using the custom port 3334
and whitelisting the eth
, net
and web3
namespaces:
--ws.origins
flag can be used to allow access to the server from web pages:
--http.corsdomain
, using the wildcard --ws.origins '*'
allows access from any origin.
By default, account unlocking is forbidden when HTTP or Websocket access is enabled (i.e. by passing
--http
or ws
flag). This is because an attacker that manages to access the node via the externally-exposed HTTP/WS port can then control the unlocked account. It is possible to force account unlock by including the --allow-insecure-unlock
flag but this is unsafe and not recommended except for expert users that completely understand how it can be used safely. This is not a hypothetical risk: there are bots that continually scan for http-enabled Parallax nodes to attackIPC Server
IPC is normally available for use in local environments where the node and the console exist on the same machine. The Parallax client creates a pipe in the computers local file system (at ipcpath) that configures a connection between node and console. Theprlx.ipc
file can also be used by other processes on the same machine to interact with the Parallax client.
On UNIX-based systems (Linux, OSX) the IPC is a UNIX domain socket. On Windows IPC is provided using named pipes. The IPC server is enabled by default and has access to all JSON-RPC namespaces.
The listening socket is placed into the data directory by default. On Linux and macOS, the default location of the Parallax client socket is
--ipcpath
flag. IPC can be disabled using the --ipcdisable
flag.
Choosing a transport protocol
The following table summarizes the relative strengths and weaknesses of each transport protocol so that users can make informed decisions about which to use.HTTP | WS | IPC | |
---|---|---|---|
Event subscription | N | Y | Y |
Remote connection | Y | Y | N |
Per-message metadata overhead | high | low | low |