For native dapps we can establish an rcp connection over IPC using

conn, err := rpc.NewIPCClient("/home/karalabe/.ethereum/testnet/geth.ipc")

Now what if I want to establish an rpc connection over http i.e.

conn, err := rpc.NewHTTPClient("")

I am unaware whether than methods exists on the rpc package nor was I able to find the documentation for the rpc package. Can anyone provide examples of using HTTP connection over rpc or the full documentation of that struct?


As discussed here, I think rpc.NewIPCClient is deprecated and replaced by rpc.Dial("****").
herefore, you can use : client = ethclient.Dial("http://*.*.*.*:8545").

From this example you'll find this snippet code:

  func getBalance(address common.Address) {
    client, err := ethclient.Dial("http://localhost:8545")

    if err != nil {
        fmt.Printf("%v", err)

    doGetBalance(client, address)
  • There's no err if the "localhost:8545" is not open. Error will be available when we use it. I recommend to use the client to check its health – Ellis Feb 9 '18 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.