4

Follow up on this post Does parity include a console?

It is possible to have a JS script -with web3 nodejs library- running in a linux machine which only has installed parity as a client (no geth)?

Thanks!

donpresente
  • 257
  • 2
  • 8

1 Answers1

6

Sure.

$ npm install web3
$ node test.js

... where test.js looks like this:

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
console.log(web3.eth.accounts);
Jamie Hale
  • 1,005
  • 7
  • 18
  • thanks! so it does not matter if the client is geth or parity (or other) the web3 will work either way? – donpresente Nov 12 '16 at 10:23
  • Correct, web3 uses the JSONRPC interface which both clients expose. (See https://github.com/ethereum/wiki/wiki/JSON-RPC) – Jamie Hale Nov 16 '16 at 01:27
  • 1
    Piles, but not that would fit or be appropriate here. But keep an eye on the --geth command-line parameter for parity. I've found that there are issues with gas estimates for contract deployment that only get resolved with you run parity --geth. See https://github.com/ethcore/parity/issues/2434 – Jamie Hale Nov 18 '16 at 15:00