# gettxout

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

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

Returns details about an unspent transaction output (UTXO), optionally including mempool data.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| txid | string | Yes | The transaction ID. |
| n | integer | Yes | The vout number. |
| include_mempool | boolean | No | Whether to include outputs spent in the mempool. Default is true.  |

## Result

**result** (object): Details about the specified unspent output, or null if not found.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "gettxout",
  "params": [
    "546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b",
    0,
    true
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "bestblock": "00000000000000000000944aba5f33a268df0c95a8bacdf42e5d10f8c7d51f94",
    "confirmations": 7,
    "value": 0.00157099,
    "scriptPubKey": {
      "asm": "OP_HASH160 53ca847feb3986cf2be405429e7e513484e0bc93 OP_EQUAL",
      "desc": "addr(39L4cdhha5ueasiKz1wRVd75fHdB9NV2t7)#29pkvxg9",
      "hex": "a91453ca847feb3986cf2be405429e7e513484e0bc9387",
      "address": "39L4cdhha5ueasiKz1wRVd75fHdB9NV2t7",
      "type": "scripthash"
    },
    "coinbase": false
  },
  "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": "gettxout",
  "params": [
    "546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b",
    1,
    true
  ]
}'
```

### JavaScript

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

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": "gettxout",
    "params": ["546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b", 1, True]
}
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\": \"gettxout\",\n  \"params\": [\n    \"546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b\",\n    1,\n    true\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\": \"gettxout\",\n  \"params\": [\n    \"546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b\",\n    1,\n    true\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\": \"gettxout\",\n  \"params\": [\n    \"546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b\",\n    1,\n    true\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: gettxout
summary: Get details about an unspent transaction output
description: |
  Returns details about an unspent transaction output (UTXO), optionally including mempool data.
params:
  - name: txid
    required: true
    description: The transaction ID.
    schema:
      title: Bitcoin Transaction ID
      type: string
      pattern: ^[a-fA-F0-9]{64}$
      description: A 64-character hex string identifying a transaction.
  - name: 'n'
    required: true
    description: The vout number.
    schema:
      type: integer
  - name: include_mempool
    required: false
    description: |
      Whether to include outputs spent in the mempool. Default is true.
    schema:
      type: boolean
      default: true
result:
  name: result
  description: Details about the specified unspent output, or null if not found.
  schema:
    type: object
    nullable: true
    properties:
      bestblock:
        title: Bitcoin Block Hash
        type: string
        pattern: ^[a-fA-F0-9]{64}$
        description: A 64-character hex string representing the block hash.
      confirmations:
        type: integer
        description: Number of confirmations for the transaction.
      value:
        type: number
        format: float
        description: The amount in BTC.
      scriptPubKey:
        type: object
        description: The public key script info.
        properties:
          asm:
            type: string
          hex:
            type: string
          address:
            type: string
          desc:
            type: string
          type:
            type: string
      coinbase:
        type: boolean
        description: True if the output is from a coinbase transaction.
examples:
  - name: gettxout example
    params:
      - name: txid
        value: 546263a196ce5cf674d5002afc0231ab417c2e971fd4ed1735c7a4c63f44720b
      - name: 'n'
        value: 0
      - name: include_mempool
        value: true
    result:
      name: result
      value:
        bestblock: 00000000000000000000944aba5f33a268df0c95a8bacdf42e5d10f8c7d51f94
        confirmations: 7
        value: 0.00157099
        scriptPubKey:
          asm: OP_HASH160 53ca847feb3986cf2be405429e7e513484e0bc93 OP_EQUAL
          desc: addr(39L4cdhha5ueasiKz1wRVd75fHdB9NV2t7)#29pkvxg9
          hex: a91453ca847feb3986cf2be405429e7e513484e0bc9387
          address: 39L4cdhha5ueasiKz1wRVd75fHdB9NV2t7
          type: scripthash
        coinbase: false
```
