> For the complete documentation index, see [llms.txt](https://docs.taal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taal.com/core-products/whatsonchain/script.md).

# Script

## Get Script Usage Status

This endpoint serves as a usage status flag for a given script.

{% code title="HTTP Request" %}

```
GET https://api.whatsonchain.com/v1/<chain>/<network>/script/<scriptHash>/used
```

{% endcode %}

#### Example Request

{% tabs %}
{% tab title="BSV" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/bsv/main/script/3a9b9e2285ae40de7679e48efcef7d029a46a7b3120063a6d24347ce4452e6ee/used"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/btc/main/script/6cf6b0690edac65afb8ba0aede291027af7aed93a81e590a0f5b381eae09f5ab/used"
```

{% endtab %}
{% endtabs %}

#### Example Response

{% tabs %}
{% tab title="BSV" %}

```
false
```

{% endtab %}

{% tab title="BTC" %}

```
true
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter  | Description                                                                                                               |
| ---------- | ------------------------------------------------------------------------------------------------------------------------- |
| chain      | Desired blockchain: `bsv` or `btc`.                                                                                       |
| network    | Selected network: `main` or `test`.                                                                                       |
| scriptHash | Script hash: `Sha256` hash of the binary bytes of the locking script (`ScriptPubKey`), expressed as a hexadecimal string. |

## Get Unconfirmed Script History

This endpoint retrieves  the history of unconfirmed transactions for a given script.

{% hint style="info" %}
Returns up to 100k results in one request.
{% endhint %}

{% code title="HTTP Request" %}

```
GET https://api.whatsonchain.com/v1/bsv/<network>/script/<scriptHash>/unconfirmed/history
```

{% endcode %}

#### Example Request

{% tabs %}
{% tab title="BSV" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/bsv/main/script/0374d9ee2df8e5d7c5fd8359f33456996f2a1a9c76d9c783d2f8d5ee05ba5832/unconfirmed/history"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/btc/main/script/fdedaf756e9eec43f745da5c3c4047d9f1cac9569f9236713238f69730435787/unconfirmed/history"
```

{% endtab %}
{% endtabs %}

#### Example Response

{% tabs %}
{% tab title="BSV" %}

```json
{
    "script": "f80a9ad71e1f2a5e83bfddb639e87e0c0bdeefd6f1b4f760dd0f88ccae3a8441",
    "result": [{
        "tx_hash": "2ee65e24a9cd8ba26305c8754d306680a8fba9931ac569e91f230cbb8595cf4f"
    }, {
        "tx_hash": "1dc75c98dd544093db8c10ea68bdab36e1b209f17b41b12bfadceccdaea3a15d"
    },
    ...
    ],
    "error": ""
}
```

{% endtab %}

{% tab title="BTC" %}

```json
{
    "script": "fdedaf756e9eec43f745da5c3c4047d9f1cac9569f9236713238f69730435787",
    "result": [{
        "tx_hash": "697c41528c239fd869bd876513e2c9afd48d7e3caa9d3b35cf459df0f807b262"
    }, {
        "tx_hash": "057490809f6cf77c588aeab5416be313feb0a3e91bd8585e06c34b04e4af472d"
    }],
    "error": ""
}
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter  | Description                                                                                                               |
| ---------- | ------------------------------------------------------------------------------------------------------------------------- |
| network    | Selected network: `main` or `test`.                                                                                       |
| scriptHash | Script hash: `Sha256` hash of the binary bytes of the locking script (`ScriptPubKey`), expressed as a hexadecimal string. |

## Bulk Unconfirmed Script History

This endpoint retrieves  the history of unconfirmed transactions for a given set of scripts.

{% hint style="info" %}

* Max 20 script hashes per request.
* Max 100 items returned per request.
  {% endhint %}

{% code title="HTTP Request" %}

```
POST https://api.whatsonchain.com/v1/bsv/<network>/scripts/unconfirmed/history
```

{% endcode %}

{% code title="Request Data" %}

```json
{
    "scripts": [
        "<script>",
        "<script>",
        ...
    ]
}
```

{% endcode %}

#### Example Request

{% tabs %}
{% tab title="BSV" %}

```sh
curl --location --request POST "https://api.whatsonchain.com/v1/bsv/main/scripts/unconfirmed/history" \
  --header "Content-Type: application/json" \
  --data "{\"scripts\" : [ \"f80a9ad71e1f2a5e83bfddb639e87e0c0bdeefd6f1b4f760dd0f88ccae3a8441\", \"a6595fcfa6ac7870f3caa04633b5d60dbbb219ecdd75fc09e0f790f35bc161bd\"] }"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request POST "https://api.whatsonchain.com/v1/btc/main/scripts/unconfirmed/history" \
  --header "Content-Type: application/json" \
  --data "{\"scripts\" : [ \"fdedaf756e9eec43f745da5c3c4047d9f1cac9569f9236713238f69730435787\", \"12eb49134d1eb488a080856a7bf2556f044dea82155f98d4c77559b0a41eb250\"] }"
```

{% endtab %}
{% endtabs %}

#### Example Response

{% tabs %}
{% tab title="BSV" %}

```sh
[{
    "script": "f80a9ad71e1f2a5e83bfddb639e87e0c0bdeefd6f1b4f760dd0f88ccae3a8441",
    "result": [{
        "tx_hash": "36f1ed66752c78c6d1e8e73a060002b056015ef646e01508e8802bd8cb180b2d"
    }, {
        "tx_hash": "2cd3963137335c982005fae40846c269cf022061cae0a28f7bccf6d53a0252c6"
    },
    ...
    ],
    "nextPageToken": "ecc52be40f3645ac03b0e0c39a8b041badebd2901955b2903e1db2c59732f90a",
    "error": ""
}, {
    "script": "a6595fcfa6ac7870f3caa04633b5d60dbbb219ecdd75fc09e0f790f35bc161bd",
    "result": [{
        "tx_hash": "807802f9a6d70951feb4841b7d8050db2d984815e3d40387ab935fa9062c8f01"
    }, {
        "tx_hash": "2fde4146ae470efb337395987261b028c38e4e095b44ae3bc800c4073daf4730"
    }, 
    ...
    ],
    "error": ""
}]
```

{% endtab %}

{% tab title="BTC" %}

```sh
[{
    "script": "fdedaf756e9eec43f745da5c3c4047d9f1cac9569f9236713238f69730435787",
    "result": [{
        "tx_hash": "697c41528c239fd869bd876513e2c9afd48d7e3caa9d3b35cf459df0f807b262"
    }, {
        "tx_hash": "057490809f6cf77c588aeab5416be313feb0a3e91bd8585e06c34b04e4af472d"
    }],
    "error": ""
}, {
    "script": "12eb49134d1eb488a080856a7bf2556f044dea82155f98d4c77559b0a41eb250",
    "result": [{
        "tx_hash": "1ae4a70085cfbea991e8d9175dd5b919c2610bbeedcc575627ea49d467adefba"
    }],
    "error": ""
}]
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter | Description                         |
| --------- | ----------------------------------- |
| network   | Selected network: `main` or `test`. |

## Get Confirmed Script History

This endpoint retrieves the history of confirmed transactions for a given script.

{% hint style="info" %}
Pagination is available using the provided `next-page` token.
{% endhint %}

{% code title="HTTP Request" %}

```
GET https://api.whatsonchain.com/v1/<chain>/<network>/script/<scriptHash>/confirmed/history
```

{% endcode %}

#### Example Request

{% tabs %}
{% tab title="BSV" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/bsv/main/script/0374d9ee2df8e5d7c5fd8359f33456996f2a1a9c76d9c783d2f8d5ee05ba5832/confirmed/history"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/btc/main/script/aebd9e3018dbb5eed9220f275d3098dad2448fecd1c4c253d8c75a780bb08ce3/confirmed/history"
```

{% endtab %}
{% endtabs %}

#### Example Response

{% tabs %}
{% tab title="BSV" %}

```json
{
    "script": "0374d9ee2df8e5d7c5fd8359f33456996f2a1a9c76d9c783d2f8d5ee05ba5832",
    "result": [{
        "tx_hash": "6cc9631ef3dad77eb0141134167f20469d0b4e61405de57fe6a9ac71b943bb9f",
        "height": 797518
    }],
    "error": ""
}
```

{% endtab %}

{% tab title="BTC" %}

```json
{
    "script": "aebd9e3018dbb5eed9220f275d3098dad2448fecd1c4c253d8c75a780bb08ce3",
    "result": [{
        "tx_hash": "a41d03a56f9864f9aa75a380e14145bf21c2cdcfcad5769d1ab7e480fa93315e",
        "height": 896169
    }, {
        "tx_hash": "ec21f0c8616a93575e7f9f9dfdec83b1c39cf7e6e06f27646aa455e36f96e0ee",
        "height": 896188
    },
    ...
    ],
    "error": ""
}
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter         | Description                                                                                                               |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------- |
| chain             | Desired blockchain: `bsv` or `btc`.                                                                                       |
| network           | Selected network: `main` or `test`.                                                                                       |
| scriptHash        | Script hash: `Sha256` hash of the binary bytes of the locking script (`ScriptPubKey`), expressed as a hexadecimal string. |
| order             | Ordering: `asc` or `desc` (default).                                                                                      |
| limit (optional)  | Between `1` and `1000`; default is `100`.                                                                                 |
| height (optional) | Starting block height for history; default is `0`.                                                                        |
| token             | Provided `next-page` token.                                                                                               |

## Bulk Confirmed Script History

This endpoint retrieves the history of confirmed transactions for a given set of scripts.

{% hint style="info" %}

* Max 20 script hashes per request.
* Max 20 items returned per request.
  {% endhint %}

{% code title="HTTP Request" %}

```
POST https://api.whatsonchain.com/v1/<chain>/<network>/scripts/confirmed/history
```

{% endcode %}

{% code title="Request Data" %}

```json
{
    "scripts": [
        "<script>",
        "<script>",
        ...
    ]
}
```

{% endcode %}

#### Example Request

{% tabs %}
{% tab title="BSV" %}

```sh
curl --location --request POST "https://api.whatsonchain.com/v1/bsv/main/scripts/confirmed/history" \
  --header "Content-Type: application/json" \
  --data "{\"scripts\" : [ \"8ca0d228066cfff2b7f31c7db7737185be9d06ff5c07206b61f06d80a4cdd9a8\", \"f5ee5d1753a33864040aee64c4103ef697116e28f66953a8b1369ac8d210b1d6\" ] }"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request POST "https://api.whatsonchain.com/v1/btc/main/scripts/confirmed/history" \
  --header "Content-Type: application/json" \
  --data "{\"scripts\" : [ \"aebd9e3018dbb5eed9220f275d3098dad2448fecd1c4c253d8c75a780bb08ce3\", \"0def09e897fd2ccf0317a6320521db9a149827cc654663466e6418619a3aa9ef\" ] }"
```

{% endtab %}
{% endtabs %}

#### Example Response

{% tabs %}
{% tab title="BSV" %}

```json
[{
    "script": "8ca0d228066cfff2b7f31c7db7737185be9d06ff5c07206b61f06d80a4cdd9a8",
    "result": [{
        "tx_hash": "d5f404cb61451034aaa19366054d26c2d30ffe475989d37dbc97c21ad9fbbf3c",
        "height": 826342
    }, {
        "tx_hash": "30d352353d7c0efb4ef17e869bc1bb780d6f2f3013e97f2dc4ec5b660643eff0",
        "height": 826342
    },
    ...
    ],
    "nextPageToken": "00000000de0000004c00000001000000400000003863613064323238303636636666663262376633316337646237373337313835626539643036666635633037323036623631663036643830613463646439613801180000000200000004000000000c9be604000000000057b6ebffffff0a46a1a48995f9b0f494c3b008eda3b5010000003900000001190000001400000001000000080000007d25cc5cb0235cc00101190000001400000001000000080000007d25cc5cb0235cc0010101000000ed4bed6135c0ae12f382dd544c57ef9a010000000000ffffffff000000000002",
    "error": ""
}, {
    "script": "f5ee5d1753a33864040aee64c4103ef697116e28f66953a8b1369ac8d210b1d6",
    "result": [{
        "tx_hash": "be2a95172191bb8a2dbe7c4215ea5bde2e1a96dad04d8f302650c00d6df033a1",
        "height": 826342
    }, {
        "tx_hash": "b0b095946d58891887a2f1274396427183e8c78be04116d28a6ff2d5b36d73e8",
        "height": 826342
    },
    ...
    ],
    "nextPageToken": "00000000de0000004c00000001000000400000006635656535643137353361333338363430343061656536346334313033656636393731313665323866363639353361386231333639616338643231306231643601180000000200000004000000000c9be60400000000005668ebffffff1343121f637efa8263cd9107bbdf029301000000390000000119000000140000000100000008000000dce928bd462018fb010119000000140000000100000008000000dce928bd462018fb010101000000ed4bed6135c0ae12f382dd544c57ef9a010000000000ffffffff000000000002",
    "error": ""
}]
```

{% endtab %}

{% tab title="BTC" %}

```json
[{
    "script": "aebd9e3018dbb5eed9220f275d3098dad2448fecd1c4c253d8c75a780bb08ce3",
    "result": [{
        "tx_hash": "e74bd31fcf4efeaea6ec32aab7d0af074ba51554352075555e0d0eb22a4eff07",
        "height": 898961
    }, {
        "tx_hash": "9b2ee6187970dbff1a696dd26297dcbc5e964e0b36145f3d1cf7ab0f204889e4",
        "height": 898841
    },
    ...
    ],
    "nextPageToken": "00000000de0000004c00000001000000400000006165626439653330313864626235656564393232306632373564333039386461643234343866656364316334633235336438633735613738306262303863653301180000000200000004000000000db79104000000000000ffebffffff6542ae3daaa4009867392cd8f52ab3a6010000003900000001190000001400000001000000080000008721a0afa4db0b3c0101190000001400000001000000080000008721a0afa4db0b3c010101000000164715117e017b366640b372f29546ae010000000000ffffffff000000000002",
    "error": ""
}, {
    "script": "0def09e897fd2ccf0317a6320521db9a149827cc654663466e6418619a3aa9ef",
    "result": [{
        "tx_hash": "5dc685c2eb98cacd5ea879b6ac40b666a4e89510982f65fa626525e91e05aa83",
        "height": 805111
    }, {
        "tx_hash": "c6a06fbc0936cc30f15869fe2be57a3d119b667d663af642763766d7db17e4e0",
        "height": 805111
    },
    ...
    ],
    "nextPageToken": "00000000de0000004c00000001000000400000003064656630396538393766643263636630333137613633323035323164623961313439383237636336353436363334363665363431383631396133616139656601180000000200000004000000000c48f70400000000000444ebffffffc74ee3c62e91b733e8f0f46aea0e488e01000000390000000119000000140000000100000008000000384f4f9c1b221a90010119000000140000000100000008000000384f4f9c1b221a90010101000000164715117e017b366640b372f29546ae010000000000ffffffff000000000002",
    "error": ""
}]
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter | Description                         |
| --------- | ----------------------------------- |
| chain     | Desired blockchain: `bsv` or `btc`. |
| network   | Selected network: `main` or `test`. |
