VOUT

The index number for an output

Diagram showing the VOUTs as index numbers for outputs in a transaction.

A VOUT is an index number for a transaction output.

A transaction can have multiple outputs, so they are each given a number so that they can be individually referenced later on.

In programming we start counting from zero. So the first output in a transaction has a VOUT of 0.

Usage

What is the VOUT used for?

You use a VOUT in combination with a TXID to help you select an output for spending as an input in a transaction.

Diagram showing an output being selected as an input for a transaction using the previous output's VOUT number.

So when you're adding inputs to a transaction, you start by finding the transaction that created the output (via its TXID) and then select the specific output you want to spend by using the output's VOUT number.

Every single output in the blockchain can be referenced by using the unique combination of TXID:VOUT. This is referred to as an "outpoint".

For example, here are a few specific outpoints from the blockchain:

Example

You can find VOUT inside the inputs of raw transaction data:

010000000001019344205e8904b78e4451eadc6120d9304c570f6697d074793c188b7dbdd74cf90300000017160014ceb587f907d67075247ddf52fb343625fd8f5a3bffffffff028c6e0000000000001976a9149e17484e1be011be7587d4f678df1123080fb5bc88acf5370100000000001976a914c1d3ab2c1c8c9f6b838c9bf25afe1454fbac22fe88ac0247304402201de904432601e724f281f97d68448cbf0610a91f32700ab5e82b88ef7ae08645022002ff2aa61254c401332648d43144887b3671b6a1ae95b11fd51dcfbd5966b4f40121029d66a6d49a1f936dc74ba588a1b693a62851159ddab4a7b3915c3ffca5e2e53000000000
{
  "version": "01000000",
  "marker": "00",
  "flag": "01",
  "inputcount": "01",
  "inputs": [
    {
      "txid": "9344205e8904b78e4451eadc6120d9304c570f6697d074793c188b7dbdd74cf9",
      "vout": "03000000",
      "scriptsigsize": "17",
      "scriptsig": "160014ceb587f907d67075247ddf52fb343625fd8f5a3b",
      "sequence": "ffffffff"
    }
  ],
  "outputcount": "02",
  "outputs": [
    {
      "amount": "8c6e000000000000",
      "scriptpubkeysize": "19",
      "scriptpubkey": "76a9149e17484e1be011be7587d4f678df1123080fb5bc88ac"
    },
    {
      "amount": "f537010000000000",
      "scriptpubkeysize": "19",
      "scriptpubkey": "76a914c1d3ab2c1c8c9f6b838c9bf25afe1454fbac22fe88ac"
    }
  ],
  "witness": [
    {
      "0": {
        "size": "47",
        "item": "304402201de904432601e724f281f97d68448cbf0610a91f32700ab5e82b88ef7ae08645022002ff2aa61254c401332648d43144887b3671b6a1ae95b11fd51dcfbd5966b4f401"
      },
      "1": {
        "size": "21",
        "item": "029d66a6d49a1f936dc74ba588a1b693a62851159ddab4a7b3915c3ffca5e2e530"
      },
      "stackitems": "02"
    }
  ],
  "locktime": "00000000"
}

Transaction: bcf91802a2aaa7de085759488b187fadf87a448f4f24f92cb38bb03285e2d8f9

This transaction has 1 input containing the following reference:

The VOUT in raw transactions is a 4-byte field in little-endian. So if we convert 03000000 to big-endian we get 00000003.

So this transaction is selecting output 3 (the fourth output) from the transaction f94cd7bd7d8b183c7974d097660f574c30d92061dcea51448eb704895e204493 for spending. If you check out that specific output you can see that it has a value of 109243 satoshis.

Coinbase

The input to a coinbase transaction doesn't reference any existing output, so the VOUT is just set to the maximum value of 0xFFFFFFFF (4294967295):

01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704b3936a1a017cffffffff01403d522a01000000434104563053b8900762f3d3e8725012d617d177e3c4af3275c3265a1908b434e0df91ec75603d0d8955ef040e5f68d5c36989efe21a59f4ef94a5cc95c99794a84492ac00000000
{
  "version": "01000000",
  "inputcount": "01",
  "inputs": [
    {
      "txid": "0000000000000000000000000000000000000000000000000000000000000000",
      "vout": "ffffffff",
      "scriptsigsize": "07",
      "scriptsig": "04b3936a1a017c",
      "sequence": "ffffffff"
    }
  ],
  "outputcount": "01",
  "outputs": [
    {
      "amount": "403d522a01000000",
      "scriptpubkeysize": "43",
      "scriptpubkey": "4104563053b8900762f3d3e8725012d617d177e3c4af3275c3265a1908b434e0df91ec75603d0d8955ef040e5f68d5c36989efe21a59f4ef94a5cc95c99794a84492ac"
    }
  ],
  "locktime": "00000000"
}

Transaction: 5b75086dafeede555fc8f9a810d8b10df57c46f9f176ccc3dd8d2fa20edd685b

Terminology

Why is it called a VOUT?

The term VOUT is short for vector output.

A vector is just another name for a list or an array of items. Satoshi programmed Bitcoin in C++, and dynamically-sized arrays in that language are called "vectors".

std::vector is a sequence container that encapsulates dynamic size arrays.
cppreference.com

So that's where the "v" in "vout" comes from:

The original Satoshi codebase used a programming style called "Hungarian notation", where variable names are prefixed with letters that indicate the data type they contain.

v in particular stands for "vector". So vin and vout just mean "in vector" and "out vector", and were (and are) the variable names for the inputs and outputs of a transaction.

Pieter Wuille, bitcoin.stackexchange.com

You can see the use of the term "vout" throughout the original version of bitcoin created by Satoshi. So the variable name "vout" originates from Satoshi's programming style, and it's a term we still use today to refer to specific outputs in a transaction.

The inputs to a transaction are also sometimes referred to as "vin"s.

Commands

You'll most commonly see the terms "vout" and "vin" when looking at raw transactions on the command line in Bitcoin Core:

bitcoin-cli getrawtransaction [txid]

Get raw transaction data for a TXID.

$ bitcoin-cli getrawtransaction bcf91802a2aaa7de085759488b187fadf87a448f4f24f92cb38bb03285e2d8f9 1

{
  "txid": "bcf91802a2aaa7de085759488b187fadf87a448f4f24f92cb38bb03285e2d8f9",
  "hash": "53fa67b27d94a10e9c4142eb5488292c88c7593aa6821fde73bde33cc17287c8",
  "version": 1,
  "size": 251,
  "vsize": 170,
  "weight": 677,
  "locktime": 0,
  "vin": [
    {
      "txid": "f94cd7bd7d8b183c7974d097660f574c30d92061dcea51448eb704895e204493",
      "vout": 3,
      "scriptSig": {
        "asm": "0014ceb587f907d67075247ddf52fb343625fd8f5a3b",
        "hex": "160014ceb587f907d67075247ddf52fb343625fd8f5a3b"
      },
      "txinwitness": [
        "304402201de904432601e724f281f97d68448cbf0610a91f32700ab5e82b88ef7ae08645022002ff2aa61254c401332648d43144887b3671b6a1ae95b11fd51dcfbd5966b4f401",
        "029d66a6d49a1f936dc74ba588a1b693a62851159ddab4a7b3915c3ffca5e2e530"
      ],
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.00028300,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 9e17484e1be011be7587d4f678df1123080fb5bc OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9149e17484e1be011be7587d4f678df1123080fb5bc88ac",
        "address": "1FQuf16UEMg91iN39gtXq4rLnn3nrRYxd8",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 0.00079861,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 c1d3ab2c1c8c9f6b838c9bf25afe1454fbac22fe OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914c1d3ab2c1c8c9f6b838c9bf25afe1454fbac22fe88ac",
        "address": "1Jfrz24gk3pHCQq1JJeDUzCRzEHNXxXiNE",
        "type": "pubkeyhash"
      }
    }
  ],
  "hex": "010000000001019344205e8904b78e4451eadc6120d9304c570f6697d074793c188b7dbdd74cf90300000017160014ceb587f907d67075247ddf52fb343625fd8f5a3bffffffff028c6e0000000000001976a9149e17484e1be011be7587d4f678df1123080fb5bc88acf5370100000000001976a914c1d3ab2c1c8c9f6b838c9bf25afe1454fbac22fe88ac0247304402201de904432601e724f281f97d68448cbf0610a91f32700ab5e82b88ef7ae08645022002ff2aa61254c401332648d43144887b3671b6a1ae95b11fd51dcfbd5966b4f40121029d66a6d49a1f936dc74ba588a1b693a62851159ddab4a7b3915c3ffca5e2e53000000000",
  "blockhash": "00000000000000000008b02ce7917dc696fee8175e4f97fe4fe5edd2f7356de1",
  "confirmations": 94154,
  "time": 1631338350,
  "blocktime": 1631338350
}

Adding 1 or true to the end of the command allows to see the raw transaction data in JSON format.

You'll notice that the term "vout" is used to refer to the entire list of outputs in a transaction too, but in the context of selecting inputs the "vout" refers to an output's index number.

In fairness, it would be more user-friendly to just call them "inputs" and "outputs" instead of "vin"s and "vout"s, but it's shorter and cooler this way and you'll get used to it eventually anyway. Welcome to the world of programming.

Resources