decodescript - Dogecoin

This method decodes a hex-encoded script and returns its assembly form, type, and any addresses it pays to.

Parameters

ParameterTypeRequiredDescription
hexstringstringYesThe hex-encoded script

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

example.js

javascriptconst axios = require('axios');
const { data } = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
  jsonrpc: '2.0', method: 'decodescript', params: ["76a914986ae75df449ca5e04503c0baa69bbeca93fcf6188ac"], id: 'getblock.io'
});
console.log(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': 'decodescript',
        'params': ["76a914986ae75df449ca5e04503c0baa69bbeca93fcf6188ac"],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

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": "decodescript",
            "params": ["76a914986ae75df449ca5e04503c0baa69bbeca93fcf6188ac"],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "error": null,
    "id": "getblock.io",
    "result": {
        "asm": "OP_DUP OP_HASH160 986ae75df449ca5e04503c0baa69bbeca93fcf61 OP_EQUALVERIFY OP_CHECKSIG",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
            "DK31KDnpWXT5DyhZgrYY86VdQ92pp7hXmP"
        ],
        "p2sh": "A4yCtkGGYCBLPCLGZpKMvDgvmmpjKjMaJK"
    }
}

Response Parameters

ParameterTypeDescription
errornull|objectError object when the call fails, otherwise null
idstringRequest identifier matching the request
result.asmstringThe script in assembly notation
result.reqSigsnumericNumber of signatures required to spend
result.typestringScript type, such as pubkeyhash, scripthash, or multisig
result.addressesarrayAddresses the script pays to
result.p2shstringThe P2SH address that wraps this script

Use Cases

  • Script Inspection: Read what a locking script does before spending it
  • Address Extraction: Resolve the addresses behind a raw output script
  • Multisig Setup: Read the P2SH address that wraps a redeem script
  • Debugging: Confirm a constructed script decodes as intended

Error Handling

Error CodeMessageDescription
-22Argument must be hexadecimal stringThe script is not valid hex
-32700Parse errorRequest body is not valid JSON
-32603Internal errorNode failed to process the request