validateaddress - Zcash

This method validates a transparent Zcash address and returns metadata: whether the address is well-formed, whether it's P2PKH (t1) or P2SH (t3), and the raw script hash. For shielded and unified addresses, use z_validateaddress instead.

Parameters

ParameterTypeRequiredDescription
addressstringYesTransparent Zcash address to validate

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": "validateaddress",
    "params": [
        "t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua"
    ],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'validateaddress',
    params: [
        "t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua"
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'validateaddress',
        'params': [
        "t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua"
    ],
        'id': 'getblock.io'
    }
)

print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

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

Response

json{
    "jsonrpc": "2.0",
    "result": {
        "isvalid": true,
        "address": "t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua",
        "isscript": false
    },
    "id": "getblock.io"
}

Response Parameters

ParameterTypeDescription
isvalidbooleantrue if the address is well-formed
addressstringThe validated address
isscriptbooleantrue if the address is a P2SH (t3) address, false if P2PKH (t1)

Use Cases

  • Address Input Validation: Validate user-supplied addresses in wallet UIs before allowing send
  • Address Type Detection: Distinguish P2PKH from P2SH addresses to select the correct signing path
  • Explorer Search Sanity: Verify search input is a valid address before running expensive queries

Error Handling

Error CodeMessageDescription
-32602Invalid paramsAddress parameter is missing or malformed
-32603Internal errorNode failed to validate the address