# getGenesisHash

The `getGenesisHash` RPC method returns the **genesis hash** of the Solana cluster to which the queried node is connected. This hash uniquely identifies the specific network—such as **Mainnet Beta**, **Devnet**, **Testnet**, or a **custom/private cluster**.

***

#### ✅ Common Use Cases

* **Verify Connected Network**\
  Ensure your application is interacting with the intended cluster (e.g., Devnet vs. Mainnet Beta) by comparing the genesis hash.
* **Client Configuration**\
  Use the genesis hash programmatically to conditionally configure tools, wallets, or front-end applications based on the connected cluster.
* **Prevent Cross-Cluster Caching Errors**\
  Incorporate the genesis hash into cache keys to avoid serving data from one network on another—important when working with multiple environments.

***

#### 🛠 Request Parameters

This method **does not accept any parameters**.

***

#### 📦 Response Structure

The response includes:

```json
{
  "jsonrpc": "2.0",
  "result": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
  "id": 1
}
```

**`result`** (*string*):\
The **base-58 encoded genesis hash** of the connected cluster.

***

💡 **Example: Fetch the Genesis Hash**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getGenesisHash"
}
```

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function getGenesisHash(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getGenesisHash'
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getGenesisHash(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_genesis_hash(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getGenesisHash'
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_genesis_hash(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d",
  "id": 1
}
```

#### 🧠 Developer Tips

* **Unique Per Cluster**\
  Each Solana network has its own unique genesis hash. For example:
  * Mainnet Beta: `5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`
  * Devnet/Testnet: Different and distinct hashes
  * Private clusters: Will have custom genesis hashes
* **Immutable Identifier**\
  The genesis hash is set once at cluster initialization and never changes.
* **Recommended Safety Check**\
  For sensitive actions (e.g., sending real funds), applications should verify that the returned hash matches the expected cluster hash to avoid misrouting operations.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinvera.io/integration/solana/rpc/getgenesishash.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
