# validateaddress - Zcash

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

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

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `address` | string | Yes | Transparent Zcash address to validate |

## 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": "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: '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': '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": "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

| Parameter | Type | Description |
| --- | --- | --- |
| `isvalid` | boolean | `true` if the address is well-formed |
| `address` | string | The validated address |
| `isscript` | boolean | `true` 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 Code | Message | Description |
| --- | --- | --- |
| -32602 | Invalid params | Address parameter is missing or malformed |
| -32603 | Internal error | Node failed to validate the address |
