getblockhash - Dogecoin

This method returns the hash of a block at a given height in the best-block-chain.

Parameters

ParameterTypeRequiredDescription
heightnumberYesThe block height (index).

Request

curl request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getblockhash",
    "params": [3904788],
    "id": "getblock.io"
}'

axios example

javascriptconst axios = require('axios');

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "getblockhash",
    "params": [3904788],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data)))
    .catch(error => console.log(error));

python example

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = json.dumps({
    "jsonrpc": "2.0",
    "method": "getblockhash",
    "params": [3904788],
    "id": "getblock.io"
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)

rust example

rustuse reqwest::header;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header(header::CONTENT_TYPE, "application/json")
        .body(r#"{
            "jsonrpc": "2.0",
            "method": "getblockhash",
            "params": [3904788],
            "id": "getblock.io"
        }"#)
        .send()
        .await?;
    
    println!("{}", response.text().await?);
    Ok(())
}

Response

response.json

json{
    "result": "24f64485ea05250ce75a73b3549afad05e078a7d8abd54e695a957dadee264fa",
    "error": null,
    "id": "getblock.io"
}

Response Parameters

FieldTypeDescription
resultstringThe block hash at the specified height.
errornullError object (null if no error).
idstringRequest identifier.

Use Case

The getblockhash method is essential for:

  • Converting block heights to hashes
  • Block explorer navigation
  • Historical data retrieval
  • Chain traversal operations
  • Synchronization checkpoints

Error Handling

Error CodeMessageCause
-8Block height out of rangeHeight exceeds current block count.
403ForbiddenMissing or invalid ACCESS-TOKEN.