Ethereum Node Connection – How to Connect to Geth by IPC in Node.js

ethereumjsgo-ethereumnodejs

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.

Best Answer

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

Related Topic