3

I'm running Parity in warp mode on Mac OSX:

parity --warp --rpcapi "web3,eth,personal"

Then I open a new terminal and run:

node Web3 = require("Web3") web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))

However, I've heard RPC is not as safe as IPC. Is this true? Why? And how do I connect via IPC instead. Some explanation would be helpful as the difference between IPC and RPC is a bit nebulous for me.

Thank you.

1
  • There s also the latency problem. Commented Nov 29, 2020 at 14:08

3 Answers 3

4

The RPC standard is an unsecured (usually) webserver that communicates via standard HTTP messages (GET/POST/PUT/etc). If unsecured (and maybe parity provides the ability to secure it with certs of some kind), this means anyone who can access the port it's listening on will be able to control all functions exposed by that RPC.

The IPC endpoint, on the other hand, is a named pipe on the filesystem, that is protected through all the normal filesystem permissions means. This means if the user/group lacks permissions to the file handle for the pipe, they won't be able to read/write it. You could even configure the IPC pipe to be read-only for some users, and read/write for others.

Parity allows you to configure the IPC interface via a configuration file at the very least, and likely through command line flags, as well. From the web3 side, you would replace Web3.providers.HttpProvider("http://localhost:8545") with Web3.providers.IpcProvider("/path/to/ipc", net), where net is a reference to the nodejs net lib (e.g. var net = require('net');).

It's also worth pointing out that Parity appears to let you configure the interface that the RPC listens on, which allows you to limit it to just the "local" interface, by default. This puts it closer to the level of security (potentially) offered by the IPC endpoint, by restricting access to only local users. However, it still doesn't offer the per-user/per-group level of control that the IPC interface provides.

10
  • Thank you @deviatefish, this is very helpful. Seems like 'path_to_ipc' should link to the ipc file which is created when parity is launched in ipc mode. Commented Jun 8, 2017 at 21:17
  • That's correct. It looks like the default location is $HOME/.local/share/io.ethereum.parity/jsonrpc.ipc, but you'd need to be able to expand the environment variable in there to get it to work from the js side. Commented Jun 8, 2017 at 21:23
  • SORRY I"M HAVING EDITING ISSUES What does your last comment mean? I ran (running it with 'var' didn't work): > net = require('net') <br/> Because currently both of the following error out. > Web3.providers.IpcProvider("~/Library/Application\ Support/io.parity.ethereum/jsonrpc.ipc", net) > Web3.providers.IpcProvider("~/Library/Application Support/io.parity.ethereum/jsonrpc.ipc", net) Commented Jun 8, 2017 at 22:04
  • What kind of system are you running it on? When running parity, does the file exist at that location? Commented Jun 8, 2017 at 22:31
  • 1
    I'm on Max OSX Yosemite and the file does in fact exist, not sure if I should escape the space in 'Application\ Support' but either way it didn't work. Here is the partial response: IPC Connection Error { Error: connect ENOENT ~/Library/Application Support/io.parity.ethereum/jsonrpc.ipc at Object.exports._errnoException (util.js:1018:11) at exports._exceptionWithHostPort (util.js:1041:20) at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1086:14) code: 'ENOENT', errno: 'ENOENT', syscall: 'connect', address: '~/Library/Application Support/io.parity.ethereum... Commented Jun 8, 2017 at 22:40
2

In nodejs, ubuntu 16.04, Parity default installation:

var net = require('net')
var web3 = require('web3')

ipcPath = process.env["HOME"] + "/.local/share/io.parity.ethereum/jsonrpc.ipc"
provider = new web3.providers.IpcProvider(this.ipcPath, net)
1

I finally solved this issue. After running parity, you run node with the following statements:

Web3 = require("Web3")

net = require('net')

web3 = new Web3(Web3.providers.IpcProvider("/Users/{redacted}/Library/Application\ Support/io.parity.ethereum/jsonrpc.ipc",net));

Before I was simply running Web3.providers.IpcProvider("/Users/{redacted}/Library/Application\ Support/io.parity.ethereum/jsonrpc.ipc",net) without nesting it within web3 = new Web3(

2
  • @deviatefish Unfortunately, I still can't get this to work, the provider is still undefined. Is it missing a port number perhaps? Commented Jun 14, 2017 at 2:35
  • It shouldn't require a port number. Perhaps try web3 = new Web3(new Web3.providers.IpcProvider("/Users/{redacted}/Library/Application\ Support/io.parity.ethereum/jsonrpc.ipc",net));? Note the new keyword when creating the provider. You'll also need to ensure parity is actually providing the IPC pipe. Commented Jul 7, 2017 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.