getGenesisHash
Returns the genesis hash for the connected cluster.
Request
curl / JSON-RPC
{ "jsonrpc": "2.0", "id": 1, "method": "getGenesisHash"}Kit
import { createSolanaRpc } from "@solana/kit"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let genesisHash = await rpc.getGenesisHash().send(); console.log(genesisHash);web3.js
import { Connection, clusterApiUrl } from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let genesisHash = await connection.getGenesisHash(); console.log(genesisHash);Rust
use anyhow::Result;use solana_client::nonblocking::rpc_client::RpcClient;use solana_commitment_config::CommitmentConfig; #[tokio::main]async fn main() -> Result<()> { let client = RpcClient::new_with_commitment( String::from("https://rpc.openinfra.sh"), CommitmentConfig::confirmed(), ); let genesis_hash = client.get_genesis_hash().await?; println!("{:#?}", genesis_hash); Ok(())}Parameters
This method takes no parameters.
Response
{ "jsonrpc": "2.0", "result": "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC", "id": 1}| Field | Type | Description |
|---|---|---|
| result | string | Genesis hash of the cluster, as a base-58 encoded string. |