eth_protocolVersion - XDC Network RPC Method
Get the current Ethereum protocol version on XDC Network. Useful for client compatibility checks and identifying version-gated features.
Returns the current Ethereum protocol version used by the XDC Network node.
Why XDC Network? Build on the enterprise-grade blockchain for trade finance with 2-second finality and ISO 20022 compliance with ISO 20022 messaging, ITFA membership, Contour Network acquisition, 801M+ transactions, and partnerships with Circle and Deutsche Telekom.
When to Use This Method
eth_protocolVersion is useful for trade finance developers, enterprise blockchain teams, and RWA tokenization builders:
- Client Compatibility — Verify that a node supports the protocol version your application requires
- Version-Gated Features — Enable or disable features based on the protocol version (e.g., EIP-1559 support)
- Multi-Client Environments — Ensure consistent protocol versions across a fleet of nodes
- Debugging — Diagnose issues caused by protocol version mismatches between clients
Request Parameters
This method accepts no parameters.
Response Body
The current Ethereum protocol version as a string (e.g., "0x41" for protocol version 65)
Error Responses
Code Examples
curl -X POST https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_protocolVersion",
"params": [],
"id": 1
}'// Using fetch
const response = await fetch('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_protocolVersion',
params: [],
id: 1
})
});
const { result } = await response.json();
const version = parseInt(result, 16);
console.log('XDC Network protocol version:', version);
// Using ethers.js
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY');
const protocolVersion = await provider.send('eth_protocolVersion', []);
console.log('XDC Network protocol version:', parseInt(protocolVersion, 16));import requests
def get_protocol_version():
response = requests.post(
'https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY',
json={
'jsonrpc': '2.0',
'method': 'eth_protocolVersion',
'params': [],
'id': 1
}
)
result = response.json()['result']
return int(result, 16)
version = get_protocol_version()
print(f'XDC Network protocol version: {version}')
# Using web3.py
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY'))
print(f'XDC Network protocol version: {w3.eth.protocol_version}')package main
import (
"context"
"fmt"
"log"
"github.com/ethereum/go-ethereum/rpc"
)
func main() {
client, err := rpc.Dial("https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY")
if err != nil {
log.Fatal(err)
}
var result string
err = client.CallContext(context.Background(), &result, "eth_protocolVersion")
if err != nil {
log.Fatal(err)
}
fmt.Printf("XDC Network protocol version: %s\n", result)
}Common Use Cases
1. Node Compatibility Check
Verify protocol version before enabling features:
async function checkCompatibility(provider, minVersion) {
const result = await provider.send('eth_protocolVersion', []);
const version = parseInt(result, 16);
if (version >= minVersion) {
console.log(`Node supports required protocol version ${minVersion}`);
return true;
} else {
console.warn(`Node protocol version ${version} is below required ${minVersion}`);
return false;
}
}2. Multi-Node Version Audit
Check protocol consistency across a fleet of XDC Network nodes:
async function auditNodeVersions(endpoints) {
const results = await Promise.all(
endpoints.map(async (endpoint) => {
const provider = new JsonRpcProvider(endpoint);
const [protocolVersion, clientVersion] = await Promise.all([
provider.send('eth_protocolVersion', []),
provider.send('web3_clientVersion', [])
]);
return {
endpoint,
protocolVersion: parseInt(protocolVersion, 16),
clientVersion
};
})
);
const versions = new Set(results.map(r => r.protocolVersion));
if (versions.size > 1) {
console.warn('Protocol version mismatch detected across nodes');
}
return results;
}3. Feature Detection
Enable features based on the protocol version:
async function getNodeCapabilities(provider) {
try {
const version = parseInt(await provider.send('eth_protocolVersion', []), 16);
return {
protocolVersion: version,
supportsEIP1559: version >= 65,
supportsSnapSync: version >= 66
};
} catch {
// Some clients (e.g., post-Merge) may not support this method
return { protocolVersion: null, supportsEIP1559: true, supportsSnapSync: true };
}
}Error Handling
Common errors and solutions:
| Error Code | Description | Solution |
|---|---|---|
| -32601 | Method not found | Some post-Merge clients no longer support this method |
| -32603 | Internal error | Node may be initializing — retry after delay |
| -32005 | Rate limit exceeded | Reduce request frequency |
Related Methods
web3_clientVersion— Get the client software version stringnet_version— Get the network IDeth_chainId— Get the chain ID (EIP-155)
web3_sha3
Compute the Keccak-256 hash of given data on XDC Network. Useful for hash verification, smart contract development, and data integrity checks.
eth_mining
Check the legacy eth_mining compatibility method on XDC Network. Public endpoints often return a client-specific unsupported-method response instead of a boolean.