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

# `getrawtransaction`

Returns a transaction by ID. This method uses [80 credits](/get-started/pricing/) from your daily balance.

Pass `blockhash` to look up a confirmed transaction in a specific block. Without `blockhash`, the method searches the mempool and the transaction index.

## Parameters[​](#parameters "Direct link to Parameters")

- `txid`: (string) _[required]_ - Transaction ID.
- `verbosity`: (integer) _[optional]_ - Level of detail in the response. The default is `0`.  
  - `0` - Returns the serialized transaction as a hex-encoded string.
  - `1` - Returns a decoded transaction object.
  - `2` - Same as `1`, and includes `fee` and each input's `prevout` when undo data is available.
- `blockhash`: (string) _[optional]_ - Hash of the block that contains the transaction.

## Returns[​](#returns "Direct link to Returns")

`result`: (string or object) - The hex-encoded transaction when `verbosity` is `0`. Otherwise, a transaction object:

- `in_active_chain`: (boolean) _[optional]_ - `true` when the block is on the main chain. Present only when you pass `blockhash`.
- `txid`: (string) - Transaction ID.
- `hash`: (string) - Witness transaction ID (`wtxid`). Equal to `txid` when there's no witness data.
- `version`: (integer) - Transaction version.
- `size`: (integer) - Serialized size, in bytes.
- `vsize`: (integer) - Virtual size, in vbytes.
- `weight`: (integer) - Transaction weight, as defined in BIP 141.
- `locktime`: (integer) - Lock time.
- `vin`: (array) - Inputs. Each input contains:  
  - `txid`: (string) - ID of the transaction whose output is spent. Absent for coinbase inputs.
  - `vout`: (integer) - Index of the spent output. Absent for coinbase inputs.
  - `scriptSig`: (object) - Unlocking script, with `asm` and `hex` fields. Absent for coinbase inputs.
  - `coinbase`: (string) - Coinbase data, as a hex string. Present only for coinbase inputs.
  - `txinwitness`: (array) _[optional]_ - Witness stack items, as hex strings.
  - `sequence`: (integer) - Sequence number.
- `vout`: (array) - Outputs. Each output contains:  
  - `value`: (number) - Amount, in BTC.
  - `n`: (integer) - Output index.
  - `scriptPubKey`: (object) - Locking script:  
    - `asm`: (string) - Disassembled script.
    - `desc`: (string) - Inferred output descriptor.
    - `hex`: (string) - Script, as a hex string.
    - `address`: (string) _[optional]_ - Bitcoin address, when the script type has one.
    - `type`: (string) - Script type, such as `pubkey`, `pubkeyhash`, `scripthash`, `witness_v0_keyhash`, `witness_v0_scripthash`, `witness_v1_taproot`, or `nulldata`.
- `hex`: (string) - Serialized transaction, as a hex-encoded string.
- `blockhash`: (string) _[optional]_ - Hash of the block that contains the transaction. Absent for mempool transactions.
- `confirmations`: (integer) _[optional]_ - Number of confirmations. Absent for mempool transactions.
- `blocktime`: (integer) _[optional]_ - Timestamp of the block that contains the transaction, in Unix epoch seconds.
- `time`: (integer) _[optional]_ - Same as `blocktime`.

### Request[​](#request "Direct link to Request")

- curl

```
curl https://bitcoin-mainnet.infura.io/v3/<YOUR-API-KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", 1, "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"]}'

```

### Response[​](#response "Direct link to Response")

- JSON

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "in_active_chain": true,
    "txid": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
    "hash": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
    "version": 1,
    "size": 134,
    "vsize": 134,
    "weight": 536,
    "locktime": 0,
    "vin": [
      {
        "coinbase": "04ffff001d0104",
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 50.00000000,
        "n": 0,
        "scriptPubKey": {
          "asm": "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG",
          "desc": "pk(0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee)#qnv32gt7",
          "hex": "410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac",
          "type": "pubkey"
        }
      }
    ],
    "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000",
    "blockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
    "confirmations": 971402,
    "time": 1231469665,
    "blocktime": 1231469665
  }
}

```
