I'm aware that I can do this using CURL like so:

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' https://the-node-ip-address:8545

Which return the following output:




Is there a way to do this using any package from go-ethereum project? All I have with me is a node RPC URL i.e. http://123.45.678.912:8545 and I want to check if it's a Geth node or Parity node using Golang without needing to convert the CURL above to Go code.

I'm looking for something like this:

import "github.com/ethereum/go-ethereum/ethclient"
client := ethclient.Dial("http://123.45.678.912:8545")
clientType := client.Xxx() // <-- I need this method and it should return "Geth" or "Parity"

What is the method for Xxx() above?

1 Answer 1


The ethclient package doesn't provide a method for that but you can use the rpc package to do what you need. Here's a working example:

package main

import (


func main() {
    client, err := rpc.DialHTTP("https://mainnet.infura.io")
    if err != nil {

    var res string
    req := struct {
        To   string `json:"to"`
        Data string `json:"data"`

    if err := client.Call(&res, "web3_clientVersion", req, "latest"); err != nil {

    fmt.Println(res) // Geth/v1.8.22-omnibus-260f7fbd/linux-amd64/go1.11.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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