How to attach geth to a local Parity RPC port 8545?
--jsonrpcflag which listens on port
I'm trying to attach a
gethinstance, like described in the the docs:
Attach a console to a running geth instance. By default this happens over IPC on the default IPC endpoint but when necessary a custom endpoint could be specified:
geth attach # connect over IPC on default endpoint geth attach ipc:/some/path # connect over IPC on custom endpoint geth attach http://host:8545 # connect over HTTP geth attach ws://host:8546 # connect over websocket
But I get a fatal error:
Fatal: Unable to attach to geth node - Invalid endpoint
This is my tested commands:
~ $ geth attach http://127.0.0.1:8545 Fatal: Unable to attach to geth node - Invalid endpoint ~ $ geth attach http://localhost:8545 Fatal: Unable to attach to geth node - Invalid endpoint ~ $ geth attach ws://localhost:8545 Fatal: Unable to attach to geth node - Invalid endpoint
How to attach geth to a local RPC on port 8545?
When you run your Parity node, use the
--gethflag, for example,
Then go into another window and run
The output of this is:
The great thing about Parity is that you don't need to worry about turning on JSON-RPC, as it's on by default.
Another approach is to use the NodeJS web3 library, which provides the same functionality. From Parity Quick Start:
npm install web3 node # Enter REPL
Web3 = require("web3"); web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.blockNumber // Regular Geth command, except connected to Parity 743397