validateaddress - Bitcoin

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

This method returns information about the given Bitcoin address.

Parameters

Parameter
Type
Required
Description

address

string

Yes

The Bitcoin address to validate.

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "validateaddress",
    "params": ["bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"],
    "id": "getblock.io"
}'

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "isvalid": true,
        "address": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq",
        "scriptPubKey": "0014e8df018c7e326cc253f167d922d5b8e7cd25f1c9",
        "isscript": false,
        "iswitness": true,
        "witness_version": 0,
        "witness_program": "e8df018c7e326cc253f167d922d5b8e7cd25f1c9"
    }
}

Response Parameters

Field
Type
Description

isvalid

boolean

Whether the address is valid.

address

string

The validated Bitcoin address.

scriptPubKey

string

The hex-encoded scriptPubKey generated by the address.

isscript

boolean

Whether the key is a script.

iswitness

boolean

Whether the address is a witness address.

witness_version

number

The witness version (for SegWit addresses).

witness_program

string

The hex value of the witness program.

Use Case

The validateaddress method is essential for:

  • Validating user-provided addresses

  • Determining address type (legacy, SegWit, Taproot)

  • Payment form validation

  • Building address analysis tools

  • Preventing invalid transactions

  • Supporting multiple address formats

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN.

Integration With Web3

The validateaddress method helps developers:

  • Validate addresses before transactions

  • Build address type detection

  • Support all address formats

  • Implement user input validation

  • Create address analysis features

Last updated

Was this helpful?