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:

    "vout"=>0,     <----- THIS
       "3045022100a9ba4f0b8ff86e91e622f43f9b76944643a807c0f6c8b43490087a169fe7542f0220258eaa36c96faaaeb41052e8d4aa41f74950df1b1c2835cb677f201c1ee0a33901 0393a2770ce81ddd9cd1e6ef71a282261ef8c03648373db209078f7850b9ab1ad1",
    "vout"=>1,     <----- THIS
       "3045022100ccc460cb0b8777d14f27acb821eacae0b5316de19db03ea707c59364f098d44f0220058a4f9df9a917944299b4c52efe500d50ab28c2fd29bb7b9ff8b75f38abcd4201 03244951ad9d146a635b321816d953e54986c62ce9c92502873335531dada0156c",

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!

5 Answers 5


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).


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.


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

Look at this transaction. 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.

  • 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
    Commented Jun 2, 2013 at 19:08
  • 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
    Commented Jun 2, 2013 at 22:37
  • 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! Commented Feb 3, 2015 at 13:45

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.


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.


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 .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.