# gettxoutproof

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}

Returns a hex-encoded proof that the specified transaction(s) were included in a block. This proof can be used to verify the inclusion of transactions without relying on a full node.


Reference: https://www.alchemy.com/docs/chains/bitcoin/bitcoin-api-endpoints/gettxoutproof

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| txids | string[] | Yes | An array of transaction IDs to generate proof for. |
| blockhash | string | No | The block in which to search for the txid(s). If omitted, the node will try to locate it. |

## Result

**result** (string): A hex-encoded proof that the specified transactions are part of a block.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "gettxoutproof",
  "params": [
    [
      "546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b"
    ],
    "000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": "0080ce25cae416f1da89e4cd3b9f7674acfa3cc43e4d71e10aeb0000000000000000000029cc4a072d5cba23dd0e821d8d711f56124f19015b70abaf08ca4f2124a429fc3e23136...",
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "gettxoutproof",
  "params": [
    [
      "546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b"
    ],
    "000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'gettxoutproof',
    params: [
      ['546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b'],
      '000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b'
    ]
  })
};

fetch('https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "gettxoutproof",
    "params": [["546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b"], "000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"gettxoutproof\",\n  \"params\": [\n    [\n      \"546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b\"\n    ],\n    \"000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"gettxoutproof\",\n  \"params\": [\n    [\n      \"546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b\"\n    ],\n    \"000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"gettxoutproof\",\n  \"params\": [\n    [\n      \"546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b\"\n    ],\n    \"000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: gettxoutproof
summary: Get a proof that one or more transactions are included in a block
description: |
  Returns a hex-encoded proof that the specified transaction(s) were included in a block. This proof can be used to verify the inclusion of transactions without relying on a full node.
params:
  - name: txids
    required: true
    description: An array of transaction IDs to generate proof for.
    schema:
      type: array
      items:
        title: Bitcoin Transaction ID
        type: string
        pattern: ^[a-fA-F0-9]{64}$
        description: A 64-character hex string identifying a transaction.
  - name: blockhash
    required: false
    description: The block in which to search for the txid(s). If omitted, the node will try to locate it.
    schema:
      title: Bitcoin Block Hash
      type: string
      pattern: ^[a-fA-F0-9]{64}$
      description: A 64-character hex string representing the block hash.
result:
  name: result
  description: A hex-encoded proof that the specified transactions are part of a block.
  schema:
    type: string
examples:
  - name: gettxoutproof example
    params:
      - name: txids
        value:
          - 546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b
      - name: blockhash
        value: 000000000000000000013c7104486ef1aa53e8ac99b8a8ac02a113b58457ed8b
    result:
      name: result
      value: 0080ce25cae416f1da89e4cd3b9f7674acfa3cc43e4d71e10aeb0000000000000000000029cc4a072d5cba23dd0e821d8d711f56124f19015b70abaf08ca4f2124a429fc3e23136...
```
