Skip to main content

getrawtransaction

Overview

The 'getrawtransaction' RPC method is utilized to retrieve raw transaction data from the Bitcoin blockchain.

Request

wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
--body-data '{"jsonrpc":"2.0","id":1,"method":"getrawtransaction","params": [ ]}' \
'https://bitcoin-mainnet.node.coinapi.io'

Request Parameters

  1. txid (String) (Required):
  • Description: Identifies the transaction.
  1. verbose (Integer):
  • Default: 0
  • Description: Determines the format of the response.
    • 0: Returns hex-encoded data.
    • 1: Returns a JSON object.
    • 2: Returns a JSON object inclusive of fee and prevout details.
  1. blockhash (String):
  • Description: Specifies the block to search for the transaction.

Response

Response when verbose is true:

{
"result": {
"in_active_chain": true,
"hex": "01000000014fe3a69...",
"txid": "4d3c3bf037d4a1e8598b5d...",
"hash": "9a3bb560407fe8659c4e...",
"size": 225,
"vsize": 144,
"weight": 573,
"version": 2,
"locktime": 0,
"vin": [
{
"txid": "e29c7c3997a9f7c67c...",
"vout": 0,
"scriptSig": {
"asm": "3045022100d29d8a651edf7...",
"hex": "473044022051d81..."
},
"sequence": 4294967295,
"txinwitness": [
{
"hex": "3045022100d29d8..."
}
]
}
],
"vout": [
{
"value": 0.8995,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 7f9b1a...",
"hex": "76a9147f9b1a7e...",
"desc": "pkh([dab5b6a1/44'/0'/0'/0]03...)",
"type": "pubkeyhash",
"address": {
"str": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
}
}
}
],
"blockhash": "0000000000000bae09a7a393e0...",
"confirmations": 536,
"blocktime": 1611718263,
"time": 1611718263
},
"error": null,
"id": "curltest"
}

If verbose is unset or set to 0:

  • str: Returns the serialized, hex-encoded data corresponding to the 'txid'.

If verbose is set to 1 or 2:

  • in_active_chain: Indicates if the specified block is in the active chain (only available when 'blockhash' parameter is utilized).
  • hex: Serialized, hex-encoded data for the 'txid'.
  • txid: Identifies the transaction.
  • hash: The hash of the transaction (differs from txid for witness transactions).
  • size: Indicates the transaction size.
  • vsize: Represents the virtual transaction size (differs for witness transactions).
  • weight: Specifies the transaction weight, calculated between 'vsize*4 - 3' and 'vsize*4'.
  • version: Indicates the block version.
  • locktime: Represents the transaction locktime.
  • vin: A JSON array representing the input vectors of the transaction, comprising of:
    • txid: Transaction id.
    • vout: Output number.
    • scriptSig: Script's signature details, including:
      • asm: Script's public key as a string.
      • hex: Hex-encoded witness data.
    • sequence: Script's sequence number.
    • txinwitness: An array of JSON objects containing hex-encoded witness data.
  • vout: A JSON array with transaction output details, including:
    • value: Value in BTC.
    • n: Output index.
    • scriptPubKey: A JSON object with PubKey script information, encompassing:
      • asm: Script public key as a string.
      • hex: Hex representation of the script's public key.
      • desc: Inferred descriptor for the output.
      • type: Script type, such as pubkeyhash or multisig.
      • address: Details of the Bitcoin address, featuring:
        • str: Bitcoin address as a string.
  • blockhash: The hash of the block.
  • confirmations: The count of confirmed transactions in the block.
  • blocktime: Block time, represented in UNIX epoch time.
  • time: Echoes 'blocktime'.