17

There is nothing like parity console.

How to open the JavaScript console on Parity?

q9f
  • 32,913
  • 47
  • 156
  • 395

4 Answers4

19

Either use the geth console attached to parity or use the Parity UI application Parity/Web3 Console.

To attach Geth console to Parity, (on Linux) use:

geth attach ~/.local/share/io.parity.ethereum/jsonrpc.ipc

On MacOS use:

geth attach ~/Library/Application Support/io.parity.ethereum/jsonrpc.ipc

To access the Parity/Web3 Console, open the UI, go to Applications and open the Parity/Web3 Console:

Parity Console

q9f
  • 32,913
  • 47
  • 156
  • 395
  • folder ~/.local/share/io.parity.ethereum does not seem to exist on my case. I guess because I tried it on mac. Also Inside geth it says 'api' is not defined. @5chdn – alper Mar 18 '17 at 05:13
  • 1
    Updated my question. – q9f Mar 18 '17 at 08:35
  • Under ~/Library/Application Support/io.parity.ethereum/ folder, jsonrpc.ipc does not show up. Could it be/Users/avatar/Library/Application Support/io.parity.ethereum/ipc/parity-chain.ipc ? @5chdn. – alper Mar 18 '17 at 11:03
  • 1
    Jesus, all the platforms, I don't have a mac for testing right now. Did you find any ipc? – q9f Mar 18 '17 at 20:25
  • 2
    Yes I did find the ipc but it refuse connection :) [~]$ sudo geth attach /Users/alper/Library/Application\ Support/io.parity.ethereum/ipc/parity-chain.ipc gives an error as = Fatal: Unable to attach to remote geth: dial unix /Users/alper/Library/Application Support/io.parity.ethereum/ipc/parity-chain.ipc: connect: connection refused @5chdn – alper Mar 19 '17 at 05:33
7

A Node.js CLI Console can be used per the Parity wiki:

You can install node/NPM and use its console. Once you have node/NPM installed, you'll just need to install the latest web3 module:

$ npm install web3

From then on you just need to run node and require the web3 module:

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

After this point, you'll be able to use the web3 API from with this environment, e.g.:

> web3.eth.blockNumber
743397
eth
  • 85,679
  • 53
  • 285
  • 406
  • Could I run following command api.parity.addReservedPeer('enode://0000..0007@<IP>:<Port#>') under node? Since I was not able to run it, parity could not connect to my private network and web.eth.blockNumber returns 0. @eth – alper Mar 20 '17 at 08:05
  • 1
    @Avatar: api.parity isn't part of web3. Maybe ask a separate question and someone can answer. – eth Mar 31 '17 at 10:01
5

To open the Parity console, use geth.

geth attach http://localhost:8545
chuacw
  • 306
  • 4
  • 13
0

In addition to @eth's response; if you like to have Parity's api calls; just install parity's api package instead of web3.

$ npm install @parity/api
$ node

On node console :

>// import the actual Api class
>const Api = require("@parity/api");

>// do the setup
>const provider = new Api.Provider.Http('http://localhost:8545');
>const api = new Api(provider);

// use api.parity.addReservedPeer
api.parity.addReservedPeer("enode://d64d5f74b1715c525dc88e87a52eca1574c09593ed29401d205ecfef9fbfe52fa308f966bab3a5966da1bb74212fecdb328cddceb572c38b536c597166784347@203080240034.static.ctinets.com:35423").then((data)=> {console.log(data)})
Kerem atam
  • 402
  • 3
  • 13