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.

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.

  • 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. – Hovig Charchaflian Jun 8 '17 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. – DeviateFish Jun 8 '17 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) – Hovig Charchaflian Jun 8 '17 at 22:04
  • What kind of system are you running it on? When running parity, does the file exist at that location? – DeviateFish Jun 8 '17 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... – Hovig Charchaflian Jun 8 '17 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(

  • @deviatefish Unfortunately, I still can't get this to work, the provider is still undefined. Is it missing a port number perhaps? – Hovig Charchaflian Jun 14 '17 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. – DeviateFish Jul 7 '17 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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