> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# web3_clientVersion | Ethereum

> Ethereum API method that returns the client type and version running on the Ethereum node. web3_clientVersion on Ethereum via Chainstack.

Ethereum API method that returns the client type and version running on the Ethereum node. This information can be useful to developers to verify that a node they are connecting to is compatible with their needs.

## Parameters

* `none`

## Response

* `string` — a string identifying the type of client, version, operating system, and language version running on the node

## `web3_clientVersion` code examples

<Note>
  Learn more about the `ChainstackProvider` in `ethers.js`: [ethers ChainstackProvider Documentation](/reference/ethersjs-chainstackprovider).
</Note>

<CodeGroup>
  ```javascript ethers.js theme={"system"}
  const ethers = require("ethers");

  // Create a ChainstackProvider instance for Ethereum mainnet
  const chainstack = new ethers.ChainstackProvider("mainnet");

  const clientVersion = async () => {
    const version = await chainstack.send("web3_clientVersion");
    console.log(`Client version: ${version}`);
  };

  clientVersion();
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL"
  web3 = Web3.HTTPProvider(node_url)

  client_version = web3.provider.make_request('web3_clientVersion', [])
  print(client_version)
  ```
</CodeGroup>

## Use case

A use case for the `web3_clientVersion` method can be to verify which client is running to then decide which method to run.

Let's say you have a DApp that needs to retrieve all of the transaction receipts in a block; the Erigon client has a method for this, `eth_getBlockReceipts`, but with Geth, this method is only available starting from V1.13.0. You can use the `web3_clientVersion` method in your logic to identify which client you are using to see if you have the method available.

<Note>
  Read [Expanding your blockchain horizons: The eth\_getBlockReceipts emulator](/docs/expanding-your-blockchain-horizons-the-eth_getblockreceipts-emulator) to learn how to build a program to emulate `eth_getBlockReceipts` on any EVM-compatible chain.
</Note>

Here is an implementation of this use case using ethers.js:

```javascript index.js theme={"system"}
const ethers = require("ethers");

// Create a ChainstackProvider instance for Ethereum mainnet
const chainstack = new ethers.ChainstackProvider("mainnet");

// Call eth_getBlockReceipts, which has no dedicated ethers helper
async function getBlockReceipts(blockNumber) {
  return chainstack.send("eth_getBlockReceipts", [blockNumber]);
}

// Get client version
async function getClient() {
  const client = await chainstack.send("web3_clientVersion", []);
  return client;
}

// Extract the client's name and version
async function getClientName() {
  const clientVersion = await getClient();
  
  // Split the clientVersion string by '/'
  let parts = clientVersion.split('/');
  
  // Split the second part by '-' and take the first element
  let version = parts[1].split('-')[0];

  // Concatenate the client name and version
  let clientNameWithVersion = parts[0] + '/' + version;
  console.log(clientNameWithVersion);
  return clientNameWithVersion;
}

// Parse version from version string
function parseVersion(versionString) {
  const versionMatch = versionString.match(/(\d+\.\d+\.\d+)/);
  return versionMatch ? versionMatch[1] : null;
}

// Compare versions
function isVersionGreaterThanOrEqual(v1, v2) {
  const v1Parts = v1.split('.').map(Number);
  const v2Parts = v2.split('.').map(Number);

  for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
    const num1 = v1Parts[i] || 0;
    const num2 = v2Parts[i] || 0;

    if (num1 > num2) return true;
    if (num1 < num2) return false;
  }
  return true; // versions are equal
}

// Get the receipts based on the client
async function getAllReceipts(blockId) {
  const clientNameWithVersion = await getClientName();
  const [clientName, clientVersion] = clientNameWithVersion.split('/');

  if (clientName === 'Geth') {
    const version = parseVersion(clientVersion);
    if (isVersionGreaterThanOrEqual(version, '1.13.0')) {
      console.log('Client is Geth with supported version.');
      const receipts = await getBlockReceipts(blockId);
    return receipts;
    } else {
      console.log('Client is Geth, but version is not supported.');
    }
  } else if (clientName === 'erigon') {
    console.log('Client is Erigon');
    const receipts = await getBlockReceipts(blockId);
    return receipts;
  } else {
    console.log('Client version is not Geth or Erigon');
  }
}

async function main() {
  try {
    const receipts = await getAllReceipts('latest');
    if (receipts !== undefined) {
      console.log(receipts);
    }
  } catch (error) {
    console.error(error);
  }
}

main();
```

Let's break down the code:

1. **The `getBlockReceipts` Method**:\
   The `getBlockReceipts` function is a helper that calls the `eth_getBlockReceipts` JSON-RPC method directly with `chainstack.send`, passing a single parameter `blockNumber`. Because ethers.js does not expose a dedicated helper for this method, `provider.send` is used to issue the raw JSON-RPC call and return the resulting receipts.
2. **The `getClient` Function**:\
   This function retrieves the client version by calling the `web3_clientVersion` JSON-RPC method without parameters through `chainstack.send`. It returns the full client version string.
3. **The `getClientName` Function**:\
   `getClientName` calls `getClient` to get the complete client version string. It then extracts both the client's name and its version by splitting the version string at the first `/` and `-` characters. The function concatenates these parts to form a string in the format "ClientName/Version".
4. **The `getAllReceipts` Function**:\
   This function uses `getClientName` to retrieve the name and version of the client in a combined format. It checks if the client is `Geth` and, if so, further verifies whether its version is greater than or equal to `1.13.0` using the `parseVersion` and `isVersionGreaterThanOrEqual` functions. If the client is `Geth` with a supported version or `Erigon`, the function proceeds to fetch block receipts using the `getBlockReceipts` helper. If the client is neither a supported version of `Geth` nor `Erigon`, it logs a message indicating this.
5. **Version Parsing and Comparison**:\
   Additional functions `parseVersion` and `isVersionGreaterThanOrEqual` are included for parsing the version string and comparing it against a specified minimum version. `parseVersion` extracts the semantic version number from the client version string, and `isVersionGreaterThanOrEqual` compares this version against the specified minimum version, `1.13.0` in this case.
6. **Main Function and Execution Flow**:\
   The `main` function serves as the entry point for execution. It attempts to call `getAllReceipts` with a specified block identifier, handling any exceptions and logging the results if available.


## OpenAPI

````yaml openapi/ethereum_node_api/client_info/web3_clientVersion.json POST /0a9d79d93fb2f4a4b1e04695da2b77a7
openapi: 3.0.0
info:
  title: Chainstack Node API
  version: 1.0.0
  description: This is an API for interacting with a Chainstack node.
servers:
  - url: https://nd-422-757-666.p2pify.com
security: []
paths:
  /0a9d79d93fb2f4a4b1e04695da2b77a7:
    post:
      tags:
        - Update
      summary: web3_clientVersion
      operationId: clientVersion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: web3_clientVersion
                params:
                  type: array
                  default: []
      responses:
        '200':
          description: The client running on this node.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````