# Decodescript

## decodescript

> Decodes a hex-encoded script (usually scriptPubKey) and returns a JSON representation including the script type and addresses.\
> Useful for analyzing output scripts or creating Pay-to-Script-Hash addresses.<br>

```json
{"openapi":"3.0.0","info":{"title":"BlockBook RES-API","version":"1.0.0"},"servers":[{"url":"https://btc-testnet.nownodes.io"}],"security":[{"api-keyAuth":[]}],"components":{"securitySchemes":{"api-keyAuth":{"type":"apiKey","in":"header","name":"api-key"}},"schemas":{"DecodeScriptRequest":{"type":"object","required":["jsonrpc","id","method","params"],"properties":{"jsonrpc":{"type":"string","description":"JSON-RPC version"},"id":{"type":"string","description":"Request identifier"},"method":{"type":"string","enum":["decodescript"],"description":"RPC method name"},"params":{"type":"array","minItems":1,"maxItems":1,"description":"Parameters:\n1. `hexstring` (string, required) — The script in hex format to decode.\n","items":{"type":"string"}}}},"DecodeScriptResponse":{"type":"object","properties":{"result":{"type":"object","properties":{"asm":{"type":"string","description":"Script in assembly format"},"type":{"type":"string","description":"Type of the output script (e.g. pubkeyhash, scripthash, witness_v0_keyhash)"},"reqSigs":{"type":"integer","description":"Number of required signatures (if applicable)"},"addresses":{"type":"array","items":{"type":"string"},"description":"Addresses extracted from the script (if any)"},"p2sh":{"type":"string","description":"The corresponding P2SH address for the script"}}},"error":{"type":"object","nullable":true,"description":"Null if successful; contains error info otherwise"},"id":{"type":"string","description":"Same ID as in the request"}}}}},"paths":{"/":{"post":{"tags":["decodescript"],"summary":"decodescript","description":"Decodes a hex-encoded script (usually scriptPubKey) and returns a JSON representation including the script type and addresses.\nUseful for analyzing output scripts or creating Pay-to-Script-Hash addresses.\n","operationId":"decodescript","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecodeScriptRequest"}}}},"responses":{"200":{"description":"Script decoded successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecodeScriptResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```
