getrawtransaction

How to use it

// yarn add @tatumio/tatum

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

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

const result = await tatum.rpc.getRawTransaction("c7ad51e46a39d136adc2bb7536a236136cc206ab3c8dabcd4277d4cadcf674f2")

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

Overview

The getrawtransaction RPC method retrieves a raw transaction from the blockchain or mempool. It returns the serialized (hex-encoded) transaction data. This method can be used to inspect a transaction's content before it's included in a block or to decode the transaction for further analysis.

Parameters

  • txid: (string, required) The transaction ID of the transaction to fetch.

  • verbose: (bool, optional, default=false) If set to true, the method returns a JSON object containing information about the transaction.

Return Object

If verbose is false, the method returns a hex-encoded string representing the serialized transaction data. If verbose is true, the method returns a JSON object with the following fields:

  • txid: (string) The transaction ID.

  • hash: (string) The transaction hash.

  • version: (numeric) The transaction version.

  • size: (numeric) The transaction size.

  • vsize: (numeric) The virtual transaction size.

  • weight: (numeric) The transaction's weight.

  • locktime: (numeric) The transaction locktime.

  • vin: (array) The transaction inputs. Each object within the array has the following properties:

    1. txid: A string representing the transaction ID of the output being spent. This refers to the transaction where the LTC being spent in the current transaction was received.

    2. vout: An integer representing the index of the output in the transaction specified by txid. This is the position of the output in that transaction's vout array.

    3. scriptSig: An object containing two fields, asm and hex, which represents the unlocking script that satisfies the conditions of the spent output's locking script. asm contains the assembly representation of the script while hex containing the hexadecimal representation.

    4. sequence: A number representing the sequence number of the input. It can be used to signal relative locktime constraints on the transaction.

  • vout: (array) The transaction outputs. Each object within the array has the following properties:

    1. value: A decimal number representing the amount of DOGE being sent to the output's address. This value is expressed in dogecoins (DOGE).

    2. n: An integer representing the index of the output in the transaction's vout array.

    3. scriptPubKey: An object containing information about the locking script used to lock the output. The object has the following fields:

      • asm: The assembly representation of the locking script.

      • hex: The hexadecimal representation of the locking script.

      • reqSigs: The number of required signatures to unlock the output (relevant for multisig addresses).

      • type: The type of the locking script (e.g., 'pubkeyhash', 'scripthash', 'multisig', etc.).

      • addresses: An array of Dogecoin addresses associated with the output.

  • hex: (string) The serialized transaction data in hex format.

  • blockhash: (string, optional) The block hash containing the transaction.

  • confirmations: (numeric, optional) The number of confirmations the transaction has.

  • time: (numeric, optional) The transaction time in UNIX timestamp format.

  • blocktime: (numeric, optional) The block time in UNIX timestamp format.

JSON Examples

Request example:

{
  "jsonrpc": "2.0",
  "method": "getrawtransaction",
  "params": ["c7ad51e46a39d136adc2bb7536a236136cc206ab3c8dabcd4277d4cadcf674f2", true],
  "id": 1
}

Response example:

{
    "result": {
        "txid": "c7ad51e46a39d136adc2bb7536a236136cc206ab3c8dabcd4277d4cadcf674f2",
        "hash": "c00fc27056ad4305dc65a40a78381a6c923b4311a460ceccd81401016f5c8984",
        "version": 2,
        "size": 284,
        "vsize": 203,
        "weight": 809,