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
- Example:
include_mempool
: Whether to include the mempool. Set to false to only check for outputs confirmed in the blockchain.- Example:
True
- Example:
Returns
The return object contains the following fields:
Name | Description |
---|---|
bestblock | The hash of the block at the tip of the blockchain. |
confirmations | The number of confirmations for the transaction. -1 if the transaction is not yet confirmed and in the mempool. |
value | The value of the output in BTC. |
scriptPubKey | Information 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. |
coinbase | Whether the transaction is a coinbase transaction. |
version | The transaction version. |
height | The 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