> ## Documentation Index
> Fetch the complete documentation index at: https://chainstack-docs-polygon-erigon-trace-deprecation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# web3_clientVersion | Avalanche

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

Avalanche API method that returns the client type and version running on the Avalanche 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

<CodeGroup>
  ```javascript ethers.js theme={null}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const clientVersion = async () => {
    const version = await provider.send("web3_clientVersion");
    console.log(`Client version: ${version}`);
  };

  clientVersion();
  ```

  ```python web3.py theme={null}
  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 version is running to then decide which function to call.

Let's say you have a DApp that needs to call a different function based on the client's version. You can use `web3_clientVersion` to build this logic.

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

```javascript index.js theme={null}
const ethers = require("ethers");
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

// Get client version
async function getClientVersion() {
  const clientVersion = await provider.send("web3_clientVersion");
  return clientVersion
}

// define a function to be run if the client version is 'v0.11.5'
function runFunction1() {
  console.log('Running function 1...');
}

// define a function to be run if the client version is 'v0.11.4'
function runFunction2() {
  console.log('Running function 2...');
}

// define an async function to retrieve the client version and run the appropriate function
async function runBasedOnClientVersion() {
  try {
    const clientVersion = await getClientVersion();
    console.log(`Client version: ${clientVersion}`);

    if (clientVersion === 'v0.11.5') {
      runFunction1();
    }

    else if (clientVersion === 'v0.11.4') {
      runFunction2();
    }
    // log an error if the client version is not recognized
    else {
      console.error('Unrecognized client version.');
    }
  } catch (error) {
    console.error(error);
  }
}

// call the async function to retrieve the client version and run the appropriate function
runBasedOnClientVersion();
```

This code uses the ethers.js library to connect to a blockchain node specified by the `NODE_URL` variable and retrieves the client version using the `web3_clientVersion` method. It then runs different functions based on the client version by defining two functions `runFunction1` and `runFunction2`, and using an if statement to check the client version and call the appropriate function.

The `getClientVersion` function uses `provider.send` to call the `web3_clientVersion` method directly and returns the result. This function is called within the `runBasedOnClientVersion` function to retrieve the client version.

Overall, this code demonstrates how to retrieve the client version on a blockchain node using the ethers.js library and how to use the client version to run different functions based on the version. The code can be modified to add additional functions and version checks or to perform other actions based on the client version.


## OpenAPI

````yaml openapi/avalanche_node_api/client_info/web3_clientVersion.json POST /8763cb5a211e1d4345acd51bde484c00/ext/bc/C/rpc
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-418-459-126.p2pify.com
security: []
paths:
  /8763cb5a211e1d4345acd51bde484c00/ext/bc/C/rpc:
    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

````