gettxout

Bitcoin RPC

Overview

The gettxout RPC method returns details about an unspent transaction output (UTXO). This method can be used to check if a specific transaction output is still unspent and obtain its details such as the value and scriptPubKey.

Parameters

  • txid: The transaction ID of the output.
    • Example: "a12345abcdef67890bcdef1234567890abcdef1234567890abcdef1234567890"
  • n: The index of the output within the transaction (vout).
    • Example: 1
  • include_mempool: Whether to include the mempool. Set to false to only check for outputs confirmed in the blockchain.
    • Example: True

Returns

The return object contains the following fields:

NameDescription
bestblockThe hash of the block at the tip of the blockchain.
confirmationsThe number of confirmations for the transaction. -1 if the transaction is not yet confirmed and in the mempool.
valueThe value of the output in BTC.
scriptPubKeyInformation about the output's scriptPubKey:
asm: The assembly representation of the script.
hex: The hex representation of the script.
type: The type of the script (e.g., pubkeyhash, scripthash).
addresses: The Bitcoin addresses associated with this output.
coinbaseWhether the transaction is a coinbase transaction.
versionThe transaction version.
heightThe height of the block containing this output.

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/bitcoin-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
  "jsonrpc": "2.0",
  "method": "gettxout",
  "params": ["c7ad51e46a39d136adc2bb7536a236136cc206ab3c8dabcd4277d4cadcf674f2", 1],
  "id": 1
}'
// yarn add @tatumio/tatum

import { TatumSDK, Bitcoin, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Bitcoin>({ network: Network.BITCOIN })

const result = await tatum.rpc.getTxOut('c7ad51e46a39d136adc2bb7536a236136cc206ab3c8dabcd4277d4cadcf674f2', 1)

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs