getGenesisHash
Returns the genesis hash of the cluster. The genesis hash uniquely identifies a Solana cluster (mainnet-beta, testnet, devnet) and is immutable once the cluster is initialized. This is commonly used to verify that a client is connected to the correct network, preventing accidental cross-network operations such as sending mainnet transactions to devnet.
Parameters
This method does not accept any parameters.
Response
Returns a single value:
| Field | Type | Description |
|---|---|---|
result | string | Base-58 encoded genesis hash |
Code Examples
cURL
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getGenesisHash",
"params": []
}'TypeScript
const response = await fetch("http://88.216.36.108:7999", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getGenesisHash",
params: []
}),
});
const { result } = await response.json();
console.log("Genesis hash:", result);Python
import requests
response = requests.post("http://88.216.36.108:7999", json={
"jsonrpc": "2.0",
"id": 1,
"method": "getGenesisHash",
"params": []
})
result = response.json()["result"]
print(f"Genesis hash: {result}")Rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client.post("http://88.216.36.108:7999")
.json(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": "getGenesisHash",
"params": []
}))
.send().await?
.text().await?;
println!("{}", res);
Ok(())
}Example Response
{
"jsonrpc": "2.0",
"result": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d",
"id": 1
}