<h2><strong>The input of every transaction refers to an output of a prior transaction.</strong></h2>

<p>An input can't be defined by only the transaction hash.  A transaction consists of 1 or more outputs if you only specify the transaction hash there is no way to know which output is being spent.** </p>

<p>Since these types of questions often come from a larger misunderstanding of how the network "really works" I am going to start with some "plain english" rules on transactions (tx):</p>

<pre><code>1. A tx consists of one or more inputs and one or more outputs.
2. All tx inputs refer to an unspent output of a prior transaction.
3. The full value of an input is always spent; a tx can not spend part of the value.
4. Likewise all outputs are either spent or unspent, they can't be partially spent.
5. A tx "spends" the outputs which are referenced in the input portion of the tx.
6. A tx creates new spendable "unspent outputs" listed in the output portion of the tx.
</code></pre>

<p>Now that we got that out of the way, <strong>to define a tx input you need to refer to the hash of a prior transaction AND the output index</strong>.  The tx hash identifies the transaction, but the transaction may have more than one output so the index is used to identify which output is being "spent" here.</p>

<p>This may seem confusing because you will hear statements such as "I have 20 BTC stored at address 1XYZ..." or "My wallet had 100 BTC", but this is really an abstraction.  The client is merely showing you the sum of all the unspent outputs for an address or the entire wallet.  </p>

<h2><strong>The Bitcoin network works on the concept of inputs and outputs</strong></h2>

<p>The Bitcoin network doesn't consider the "value" an address when validating txs.  When validating a tx, outputs are considered as independent entities.  Spending one output for a particular address has no effect on the other outputs (if any) for that address.  A transaction is valid (among other things)if all the inputs refer to valid unspent outputs of prior transactions (can't spend coins twice), the sum of the outputs is less than or equal to the sum of the inputs (can't counterfeit new coins), and the inputs are signed by the correct private key (only the "owner" of the private key can spend the coins).</p>

<h2><strong>Examples</strong></h2>

<p>To avoid a lot of excess detail we will look at a simplified version of the transactions used in the Bitcoin network.</p>

<p>Say an previous transaction exists (tx hash 1234567890).  In this transaction you have an input which referenced an unspent output of a previous transaction worth 100 BTC.  You send 50 BTC to one address, 10 BTC to another address, and the change (40 BTC) is sent to a new address in your wallet.  Remember we can't spend part of an unspent output so the change is necessary because we are spending a 100 BTC input but only need to "send" 60 BTC. </p>

<p>The simplified pseudo-transaction may look something like this.</p>

<pre><code>In[0] &lt;lets ignore the input for now but it does have a value of 100 BTC&gt;
Out[0] Bitcoin address=1ABC... Value=50 BTC
Out[1] Bitcoin address=1DEF... Value=10 BTC
Out[2] Bitcoin address=1XYZ... Value=40 BTC
</code></pre>

<p>The tx has 1 input, 3 outputs, all in/out indexes are zero based, and the value of the outputs is equal to the value of the input.  If the output(s) are less than the input(s) then the difference is the fee paid to the miner.  If the outputs are more than the input(s) then the tx is invalid.</p>

<p>Now since the "change" address is 1XYZ is another address in our wallet we can use it in a new transactions. We will pay a merchant 1 BTC and give the miner a fee of 0.01 for fast inclusion in a block.  The change will be sent to yet another new address in the wallet (1ZZZ....). The resulting transaction may look like this:</p>

<pre><code>In[0]  Tx hash=1234567890 OutputIndex=2
Out[0] Bitcoin Address=1HIJ... Value=1 BTC
Out[1] Bitcoin Address=1ZZZ... Value=38.99 BTC
</code></pre>

<p>The input refers to the 3rd (0 base array) output of the tx above.  Looking up the output index 2 of tx 123456789 we can see the value is 40.00 BTC.  The sum of the outputs are 39.99 meaning 0.01 BTC will be collected by the miner of the block.</p>

<h2>Real txs deviate from the simplified version shown above</h2>

<p>Note this isn't really important unless you want to dive deeper into the workings of the protocol.  The output of Bitcoin transactions are actually scripts instead of static addresses and values shown above.  Functionally for most outputs they work the same, although to save space the hash of the public key not the address is used in the output. All blocks have a required tx called the coinbase which has no input because the output is the block subsidy and the fees paid to miners.  All values in the Bitcoin network are integers in Satoshis (1E-8 BTC) so technically all the numbers in this post would be multiplied by 1E8.  </p>

CC BY-SA 3.0
2013-08-01T23:00:33.220Z
2013-08-02T22:32:53.473Z
2013-08-02T22:32:53.473Z
DeathAndTaxes
<p>A single Bitcoin transaction can have many outputs. The vout field lets you specify which output you want to spend.</p>

<p><a href="https://blockchain.info/tx/0fbf9a6f2172251611a58028bf596c3ace98b19f6f08d2b6581326c58aecda8e" rel="noreferrer">Look at this transaction</a>. Suppose you have the 1EZ5 key, but not the 199N key. You need to clarify to the Bitcoin network which output you want to spend.</p>

CC BY-SA 3.0
2013-06-02T19:08:21.607Z
I'm not sure I understand. Why would you not want to spend an output included in the transaction? Could you provide an example to demonstrate? Thanks!
Kyle Drake
CC BY-SA 3.0
2013-06-02T22:37:59.083Z
It's not that you don't want to spend the output, it's that you don't have the key to it.
Nick ODell
CC BY-SA 3.0
2015-02-03T13:45:25.370Z
A quick and to-the-point explanation for those who already know about the basics of the protocol (in contrast to @DeathAndTaxes's answer). Thanks!
Priidu Neemre
CC BY-SA 3.0
2013-06-02T02:24:50.327Z
2013-06-02T20:17:28.400Z
2013-06-02T20:17:28.400Z
Nick ODell
<p>In summary, vout refers to the index of the output address in question. The index starts from 0. So for example, if a tx has 10 output addresses, the vouts for the addresses would be from 0-9. </p>

CC BY-SA 3.0
2015-03-24T17:18:08.827Z
2015-03-24T17:18:08.827Z
Jus12
<p>In <strong>vin</strong> list <strong>vout</strong> lets you specify which output you want to spend to whom.
Every <strong>vout</strong> has its own tx_id.
and the sum of values of this <strong>vout</strong> is equal to total BTC which we have for the transaction; And if </p>

<p>if <strong>vout &lt; vin</strong> then the difference of these amount fee is to be paid to the minor.</p>

<p>else <strong>vout > vin</strong> then tx_id is invalid.</p>

CC BY-SA 4.0
2018-07-12T11:26:32.487Z
2018-07-12T11:26:32.487Z
prachi
<p>In a nutshell vout could be considered as an identifiant of the output inside a previous transaction.</p>

<p>keep in mind that the input that you want to include in your transaction are the  outputs of a previous transaction so you go back to the received transaction and you choose which output to include as input in your new transaction. However, if you don't care bitcoin client will do that in your place .</p>

CC BY-SA 3.0
2016-10-14T11:09:57.650Z
2016-10-14T11:30:00.940Z
2016-10-14T11:30:00.940Z
Badr Bellaj
<p>I'm working on trawling the bitcoin transactions coming in via getrawtransaction.</p>

<p>I haven't been able to find the neccessary documentation to describe the vout integer in the vin array:</p>

<pre><code>{"txid"=&gt;"0fbf9a6f2172251611a58028bf596c3ace98b19f6f08d2b6581326c58aecda8e",
    "vout"=&gt;0,     &lt;----- THIS
    "scriptSig"=&gt;
     {"asm"=&gt;
       "3045022100a9ba4f0b8ff86e91e622f43f9b76944643a807c0f6c8b43490087a169fe7542f0220258eaa36c96faaaeb41052e8d4aa41f74950df1b1c2835cb677f201c1ee0a33901 0393a2770ce81ddd9cd1e6ef71a282261ef8c03648373db209078f7850b9ab1ad1",
      "hex"=&gt;
       "483045022100a9ba4f0b8ff86e91e622f43f9b76944643a807c0f6c8b43490087a169fe7542f0220258eaa36c96faaaeb41052e8d4aa41f74950df1b1c2835cb677f201c1ee0a33901210393a2770ce81ddd9cd1e6ef71a282261ef8c03648373db209078f7850b9ab1ad1"},
    "sequence"=&gt;4294967295},
{"txid"=&gt;"4983504e9727a5ea73c4a0915da475faba248d0d8da265e2d270563dc3eabbaf",
    "vout"=&gt;1,     &lt;----- THIS
    "scriptSig"=&gt;
     {"asm"=&gt;
       "3045022100ccc460cb0b8777d14f27acb821eacae0b5316de19db03ea707c59364f098d44f0220058a4f9df9a917944299b4c52efe500d50ab28c2fd29bb7b9ff8b75f38abcd4201 03244951ad9d146a635b321816d953e54986c62ce9c92502873335531dada0156c",
      "hex"=&gt;
       "483045022100ccc460cb0b8777d14f27acb821eacae0b5316de19db03ea707c59364f098d44f0220058a4f9df9a917944299b4c52efe500d50ab28c2fd29bb7b9ff8b75f38abcd42012103244951ad9d146a635b321816d953e54986c62ce9c92502873335531dada0156c"},
    "sequence"=&gt;4294967295}
</code></pre>

<p>In the transactions I'm seeing, it tends to vout 0 1 0 1 0 1 in the array. What does this represent in a transaction? Do I need to interpret it in a specific way? Thanks!</p>

<transactions><bitcoind>
In getrawtransaction, what is the vout integer in the vin list?
Kyle Drake
# In getrawtransaction, what is the vout integer in the vin list?

(Asked by: username_0 on 2013-06-02)

I'm working on trawling the bitcoin transactions coming in via getrawtransaction.

I haven't been able to find the neccessary documentation to describe the vout integer in the vin array:

```
{"txid"=>"0fbf9a6f2172251611a58028bf596c3ace98b19f6f08d2b6581326c58aecda8e",
    "vout"=>0,     <----- THIS
    "scriptSig"=>
     {"asm"=>
       "3045022100a9ba4f0b8ff86e91e622f43f9b76944643a807c0f6c8b43490087a169fe7542f0220258eaa36c96faaaeb41052e8d4aa41f74950df1b1c2835cb677f201c1ee0a33901 0393a2770ce81ddd9cd1e6ef71a282261ef8c03648373db209078f7850b9ab1ad1",
      "hex"=>
       "483045022100a9ba4f0b8ff86e91e622f43f9b76944643a807c0f6c8b43490087a169fe7542f0220258eaa36c96faaaeb41052e8d4aa41f74950df1b1c2835cb677f201c1ee0a33901210393a2770ce81ddd9cd1e6ef71a282261ef8c03648373db209078f7850b9ab1ad1"},
    "sequence"=>4294967295},
{"txid"=>"4983504e9727a5ea73c4a0915da475faba248d0d8da265e2d270563dc3eabbaf",
    "vout"=>1,     <----- THIS
    "scriptSig"=>
     {"asm"=>
       "3045022100ccc460cb0b8777d14f27acb821eacae0b5316de19db03ea707c59364f098d44f0220058a4f9df9a917944299b4c52efe500d50ab28c2fd29bb7b9ff8b75f38abcd4201 03244951ad9d146a635b321816d953e54986c62ce9c92502873335531dada0156c",
      "hex"=>
       "483045022100ccc460cb0b8777d14f27acb821eacae0b5316de19db03ea707c59364f098d44f0220058a4f9df9a917944299b4c52efe500d50ab28c2fd29bb7b9ff8b75f38abcd42012103244951ad9d146a635b321816d953e54986c62ce9c92502873335531dada0156c"},
    "sequence"=>4294967295}

```

In the transactions I'm seeing, it tends to vout 0 1 0 1 0 1 in the array. What does this represent in a transaction? Do I need to interpret it in a specific way? Thanks!

**Tags:** transactions, bitcoind


---

## 5 answers

### Answer by username_1 on 2013-08-01. Score: 44

## **The input of every transaction refers to an output of a prior transaction.**

An input can't be defined by only the transaction hash. A transaction consists of 1 or more outputs if you only specify the transaction hash there is no way to know which output is being spent.\*\*

Since these types of questions often come from a larger misunderstanding of how the network "really works" I am going to start with some "plain english" rules on transactions (tx):

```
1. A tx consists of one or more inputs and one or more outputs.
2. All tx inputs refer to an unspent output of a prior transaction.
3. The full value of an input is always spent; a tx can not spend part of the value.
4. Likewise all outputs are either spent or unspent, they can't be partially spent.
5. A tx "spends" the outputs which are referenced in the input portion of the tx.
6. A tx creates new spendable "unspent outputs" listed in the output portion of the tx.

```

Now that we got that out of the way, **to define a tx input you need to refer to the hash of a prior transaction AND the output index**. The tx hash identifies the transaction, but the transaction may have more than one output so the index is used to identify which output is being "spent" here.

This may seem confusing because you will hear statements such as "I have 20 BTC stored at address 1XYZ..." or "My wallet had 100 BTC", but this is really an abstraction. The client is merely showing you the sum of all the unspent outputs for an address or the entire wallet.

## **The Bitcoin network works on the concept of inputs and outputs**

The Bitcoin network doesn't consider the "value" an address when validating txs. When validating a tx, outputs are considered as independent entities. Spending one output for a particular address has no effect on the other outputs (if any) for that address. A transaction is valid (among other things)if all the inputs refer to valid unspent outputs of prior transactions (can't spend coins twice), the sum of the outputs is less than or equal to the sum of the inputs (can't counterfeit new coins), and the inputs are signed by the correct private key (only the "owner" of the private key can spend the coins).

## **Examples**

To avoid a lot of excess detail we will look at a simplified version of the transactions used in the Bitcoin network.

Say an previous transaction exists (tx hash 1234567890). In this transaction you have an input which referenced an unspent output of a previous transaction worth 100 BTC. You send 50 BTC to one address, 10 BTC to another address, and the change (40 BTC) is sent to a new address in your wallet. Remember we can't spend part of an unspent output so the change is necessary because we are spending a 100 BTC input but only need to "send" 60 BTC.

The simplified pseudo-transaction may look something like this.

```
In[0] <lets ignore the input for now but it does have a value of 100 BTC>
Out[0] Bitcoin address=1ABC... Value=50 BTC
Out[1] Bitcoin address=1DEF... Value=10 BTC
Out[2] Bitcoin address=1XYZ... Value=40 BTC

```

The tx has 1 input, 3 outputs, all in/out indexes are zero based, and the value of the outputs is equal to the value of the input. If the output(s) are less than the input(s) then the difference is the fee paid to the miner. If the outputs are more than the input(s) then the tx is invalid.

Now since the "change" address is 1XYZ is another address in our wallet we can use it in a new transactions. We will pay a merchant 1 BTC and give the miner a fee of 0.01 for fast inclusion in a block. The change will be sent to yet another new address in the wallet (1ZZZ....). The resulting transaction may look like this:

```
In[0]  Tx hash=1234567890 OutputIndex=2
Out[0] Bitcoin Address=1HIJ... Value=1 BTC
Out[1] Bitcoin Address=1ZZZ... Value=38.99 BTC

```

The input refers to the 3rd (0 base array) output of the tx above. Looking up the output index 2 of tx 123456789 we can see the value is 40.00 BTC. The sum of the outputs are 39.99 meaning 0.01 BTC will be collected by the miner of the block.

## Real txs deviate from the simplified version shown above

Note this isn't really important unless you want to dive deeper into the workings of the protocol. The output of Bitcoin transactions are actually scripts instead of static addresses and values shown above. Functionally for most outputs they work the same, although to save space the hash of the public key not the address is used in the output. All blocks have a required tx called the coinbase which has no input because the output is the block subsidy and the fees paid to miners. All values in the Bitcoin network are integers in Satoshis (1E-8 BTC) so technically all the numbers in this post would be multiplied by 1E8.


---

### Answer by username_2 on 2013-06-02. Score: 6

A single Bitcoin transaction can have many outputs. The vout field lets you specify which output you want to spend.

[Look at this transaction](https://blockchain.info/tx/0fbf9a6f2172251611a58028bf596c3ace98b19f6f08d2b6581326c58aecda8e). Suppose you have the 1EZ5 key, but not the 199N key. You need to clarify to the Bitcoin network which output you want to spend.

> **Comments:**
> **username_0**: I'm not sure I understand. Why would you not want to spend an output included in the transaction? Could you provide an example to demonstrate? Thanks!  
> **username_2**: It's not that you don't want to spend the output, it's that you don't have the key to it.  
> **username_3**: A quick and to-the-point explanation for those who already know about the basics of the protocol (in contrast to @username_1's answer). Thanks!  

---

### Answer by username_4 on 2015-03-24. Score: 0

In summary, vout refers to the index of the output address in question. The index starts from 0. So for example, if a tx has 10 output addresses, the vouts for the addresses would be from 0-9.


---

### Answer by username_5 on 2018-07-12. Score: 0

In **vin** list **vout** lets you specify which output you want to spend to whom.
Every **vout** has its own tx\_id.
and the sum of values of this **vout** is equal to total BTC which we have for the transaction; And if

if **vout < vin** then the difference of these amount fee is to be paid to the minor.

else **vout > vin** then tx\_id is invalid.


---

### Answer by username_6 on 2016-10-14. Score: -1

In a nutshell vout could be considered as an identifiant of the output inside a previous transaction.

keep in mind that the input that you want to include in your transaction are the outputs of a previous transaction so you go back to the received transaction and you choose which output to include as input in your new transaction. However, if you don't care bitcoin client will do that in your place .


---

