web3_clientVersion
curl --request POST \
--url https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "web3_clientVersion",
"params": []
}
'import requests
url = "https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af"
payload = {
"id": 1,
"jsonrpc": "2.0",
"method": "web3_clientVersion",
"params": []
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({id: 1, jsonrpc: '2.0', method: 'web3_clientVersion', params: []})
};
fetch('https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'method' => 'web3_clientVersion',
'params' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af"
payload := strings.NewReader("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"web3_clientVersion\",\n \"params\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af")
.header("Content-Type", "application/json")
.body("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"web3_clientVersion\",\n \"params\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"web3_clientVersion\",\n \"params\": []\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}Gnosis Chain node API
web3_clientVersion | Gnosis
Gnosis Chain API method that returns the client type and version running on the Gnosis Chain node. Use it on Gnosis via Chainstack.
POST
/
512e720763b369ed620657f84d38d2af
web3_clientVersion
curl --request POST \
--url https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "web3_clientVersion",
"params": []
}
'import requests
url = "https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af"
payload = {
"id": 1,
"jsonrpc": "2.0",
"method": "web3_clientVersion",
"params": []
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({id: 1, jsonrpc: '2.0', method: 'web3_clientVersion', params: []})
};
fetch('https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'method' => 'web3_clientVersion',
'params' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af"
payload := strings.NewReader("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"web3_clientVersion\",\n \"params\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af")
.header("Content-Type", "application/json")
.body("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"web3_clientVersion\",\n \"params\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://nd-500-249-268.p2pify.com/512e720763b369ed620657f84d38d2af")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"web3_clientVersion\",\n \"params\": []\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}Gnosis Chain API method that returns the client type and version running on the Gnosis Chain node. This information can be useful to developers to verify that a node they are connecting to is compatible with their needs.
This code uses the ethers.js library to connect to a blockchain node specified by the
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
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
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();
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)
Use case
A use case for theweb3_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:
index.js
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");
const clientName = clientVersion.split('/')[1];
return clientName
}
// define a function to be run if the client version is 'vv2.0.10'
function runFunction1() {
console.log('Running function 1...');
}
// define a function to be run if the client version is 'vv2.0.11'
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 === 'v1.14.7+4fe81c6b') {
runFunction1();
}
else if (clientVersion === 'v1.14.8+4fe81c6b') {
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();
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.Last modified on June 25, 2026
Was this page helpful?