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
address
string
Yes
Transparent Zcash address to validate
Request
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"
}'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);Response
{
"jsonrpc": "2.0",
"result": {
"isvalid": true,
"address": "t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua",
"isscript": false
},
"id": "getblock.io"
}Response Parameters
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
-32602
Invalid params
Address parameter is missing or malformed
-32603
Internal error
Node failed to validate the address
Last updated
Was this helpful?