Understanding Bitcoin Transaction Inputs and Outputs - Blockchain Technology Explained

in #bitcoin6 years ago (edited)

In this article I explore the terms input and output of Bitcoin transactions and explain it in simple terms.

Exploring transactions
image source

A lively Chain of transactions

The Bitcoin protocol is a very complex construct and arguably the 8th world wonder. Digging into the code and understanding the magic is a never ending adventure to me.

The way our "balance" is actually determined by the blockchain is quite different from what you might expect. Let's explore the chain of transactions a little and see what is going on behind the scenes. To do this we must learn what the two components, Inputs and Outputs actually mean.

Input

An input is a reference to an output of a previous transaction. One transaction can contain multiple inputs. These input values are combined to give a total that represents your balance. You see, in bitcoin, the added amount of unspent (previous) transaction outputs are the coins you may claim, and what we call balance. The output of this transaction will be constructed as the Sum_of_Inputs - Transaction_fee = Sum_of_Outputs.

Furthermore, a script component is included, that contains your signature and public key. The public key is used to verify your signature to prove that you are the address owner and are entitled to claim the coins referenced in the transaction input.

The input is your way to redeem coins.

Output

The output is comprised of instructions for spending the coins. The output value shows how much the total value of claimed coins amounts to. There can be multiple outputs but in sum they must equal to the sum of input less the transaction fee. A single output from one transaction may only be referenced once, as an input of the next transaction. Therefore, the entire value of the input needs to be spent in the output of the next transaction. Otherwise it will be lost.

Example

Imagine you had 0 BTC and somebody sent you 10 BTC. You may say you "own" 10 BTC now. That is - your keys allow you to redeem the unspent 10 BTC (as a Transaction Input). Now you want to send 5 BTC to your friend. Executing the "send 5 BTC" operation creates 1 input equal to 10 BTC and 2 outputs: One will send 5 BTC to your friend and the other one will send 5 BTC back to you (change). If you fail to do so, the other 5 BTC will be lost. (Actually, the miner will claim them).
Picture it as a bank notes: any single output is automatically a "note". You have to spend all of it, not just half and you get the change back. But in Bitcoin this note can have any value 0.1, 0.2, 1, 5 ...whatever. (Your friend now has to spend 5 BTC in his future transaction).


image source

Can you spot it? Address 336x.. is sending some change back.

At this point we note down some rules:

  1. A transaction output sum is always equal to the transaction input sum, minus the fee
  2. The sum of unspent transaction outputs you can reference are your balance
  3. Single transaction outputs are indivisible
  4. You must always spend the full amount of a single output or the remaining coins will be lost

Don't be alarmed: This is theory, showing how bitcoin code actually works. Most wallets provide this functionality under the hood when you click "send", you don't have to worry about any of it.

But it's good to know.

The best way to learn is actually browsing through the blockchain explorer yourself and following some transactions, have a go: https://blockchain.info


More Articles like this:
Do you want to learn about a secure and safe Google alternative? (Read article)
Do you want to know how to protect Internet Freedom? (Read article)

Thank you for visiting my blog! If you enjoy my content, you are welcome to follow me for more updates. ᕦ(ò_óˇ)ᕤ
- Nick ( @cryptonik ) -

Cryptonik-Logo

Sort:  

I had no idea that is how it worked. I always thought you just sent some portion out of your wallet but the rest stayed. I guess this makes sense from a math perspective though.

Me neither. The wallets are nothing else but a very comfortable "browser" of the blockchain that only shows "our coins". When your wallet shows your balance, what it actually does is calculate all transaction outputs from different sources that you may "claim" and bundles them to display a sum balance. I was particularly surprised that you always have to spend all your Bitcoin at once. In your wallet view, you just click "send" and as small amount gets transferred - But on the blockchain actually all your BTC gets spent at once and the rest gets sent back to you.

It's different to our traditional concept of static wallets and bank accounts. But if you picture the blockchain as an ever-moving chain of transactions, one referencing the next one, the it makes sense :)

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by Reaper7132 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews/crimsonclad, and netuoso. The goal is to help Steemit grow by supporting Minnows and creating a social network. Please find us in the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP. Be sure to leave at least 50SP undelegated on your account.

The @OriginalWorks bot has determined this post by @cryptonik to be original material and upvoted it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.034
BTC 66499.54
ETH 3203.31
USDT 1.00
SBD 4.14