10

This this the command line i have used to get geth running.

geth ipc --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --ipcpath "/root/.ethereum_experiment/geth.ipc"

so from node js how to connect to this geth client, before this i was doing rpc and connected using http providers but i want the connection over IPC not over RPC.

niksmac
  • 9,673
  • 2
  • 40
  • 72
Subhod I
  • 927
  • 1
  • 9
  • 18

2 Answers2

6

according to the documentation you can do:

$ geth attach ipc:/some/custom/path
$ geth attach http://191.168.1.1:8545
$ geth attach ws://191.168.1.1:8546

So the 1st line is what you want, just replace /some/custom/path with /root/.ethereum_experiment/geth.ipc

edit : just saw you want to do it on nodejs, I didn't test it but using the provider with ipc:/some/custom/path should be ok

Philip Rego
  • 205
  • 1
  • 3
  • 13
euri10
  • 4,640
  • 5
  • 24
  • 55
5

Since you asked specifically about Node.js, see my answer to the similar question Getting contract balance over JSON RPC

TL;DR use the official web3 JavaScript library which handles connecting to the server over RPC and gives you easy access to query it for data.

See the question I linked for more details.

Ross Perkins
  • 776
  • 6
  • 11