# z_validateaddress - Zcash

> Example code for the z_validateaddress JSON-RPC method. Complete guide on how to use the z_validateaddress JSON-RPC method in GetBlock.io Web3 documentation.

This method validates a Zcash shielded or unified address (Sapling `zs`, Orchard, or Unified `u`) and returns type-specific metadata. Unified addresses can contain multiple receivers (transparent + Sapling + Orchard); the response indicates which types are present. Use `validateaddress` for transparent addresses.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `address` | string | Yes | Shielded or Unified Zcash address |

## Request

#### cURL

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

#### Axios

#### example.js

```javascript
const axios = require('axios');

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

console.log(response.data.result);
```

#### Request

#### example.py

```python
import requests

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

print(response.json())
```

#### Rust

#### example.rs

```rust
use 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": "z_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",
        "address_type": "p2pkh",
        "ismine": false
    },
    "id": "getblock.io"
}
```

## Response Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `isvalid` | boolean | `true` if the address is well-formed |
| `address_type` | string | Address type: `sapling`, `orchard`, `unified`, or `p2pkh`/`p2sh` for transparent |
| `address` | string | The validated address |
| `receiver_types` | array of string | For unified addresses: list of receiver types included (`orchard`, `sapling`, `p2pkh`, `p2sh`). Returned for Unified Addresses only |

## Use Cases

* **Shielded Wallet Input Validation**: Verify shielded and unified addresses before allowing send
* **Unified Address Introspection**: Determine which receiver types a unified address supports to select the appropriate spending pool
* **Address Migration Support**: Detect legacy Sapling addresses vs modern Orchard/unified addresses in wallet UX
* **Compliance Address Type Reporting**: Distinguish shielded vs transparent activity for jurisdictional reporting

## Error Handling

| Error Code | Message | Description |
| --- | --- | --- |
| -8 | Invalid address | Address is not a valid shielded or unified Zcash address |
| -32602 | Invalid params | Address parameter is missing or malformed |
| -32603 | Internal error | Node failed to validate the address |
