Transactions (Stage 2)

So now that we have a clear understanding of the structure and purpose of identity in Bitcoin, we can start asking the question, “How do we make transactions between one another in Bitcoin?” After all, that’s the primary goal of the Bitcoin network — to enable secure transactions between any two users in the network.

As we did before with the concept of identity, we will now be analyzing the idea of a transaction.
Take a moment to ask yourself, “What makes a transaction valid?”


For a transaction to be valid, it must have these three components: (1) a proof of ownership, aka a signature (2) available and sufficient funds to spend, and (3) a guarantee that no other transaction is using or has used the same funds.
Let’s understand these criteria in the context of checks and banks:
When you want to make a transaction via a check, you have to sign the check to validate it — that’s a proof of ownership. The bank then has to verify that you have enough funds in your account — that you have available and sufficient funds for the transaction.
They must also ensure that you do not spend the same money more than once — that you cannot send two or more checks each spending 100 dollars when your account only has 100 in total.
To ensure that one one uses funds not in their possession, all the same conditions apply to Bitcoin.
To enforce this, Bitcoin uses what’s known as a UTXO, or Unspent Transaction Output, model.

Traditionally, when we think of banks, we think of a single account where all our funds are aggregated into one count.

For example, after buying a ten dollars worth of burgers and fries, your account balance goes from twenty to ten dollars.

This is not the case with Bitcoin.

Accounts are easy for users to understand but surprisingly difficult for computers when it comes to all the complexity of a decentralized network.

There is no longer a central entity to track all the transactions being made by my account, nor a central clock to track when transactions are being made.

If I make three different transactions of 5 bitcoins from an account of only 10 bitcoins, which of the two transactions should go through? How do we ensure that we do not accidentally let all three transactions go through? To make transaction processing much easier and more secure, users do not spend from an account; instead, they spend directly from transactions made to them.

An easy way to wrap our heads around this unintuitive model is to think of UTXOs as piggy banks! [piggy] Every time a transaction is made to us, we put all that money into a UTXO, or piggy bank.

When we want to spend money, we break open that piggy bank,…

[SMASH] spend whatever we like, and then put the rest into another piggy bank.

(It’s hard to put a piggy bank’s shattered pieces back together.) This way, the complexity of checking for transaction validity goes down.

Instead of asking the more difficult question, “Is this account trying to, at this time, spend more money than it owns across multiple transactions?,” we only need to ask, “Does this single piggy bank have enough funds?” On the other hand, the complexity of keeping track of one’s own funds goes up, as each of these piggy banks has to be tracked and secured individually.

The amount of bitcoin you own is calculated by summing up the value of each of your piggy banks, or UTXOs.

  Here’s an example of how transactions work in Bitcoin: Let’s say that Gloria has two UTXOs, from past transactions, one worth one hundred (100) bitcoins… and one worth fifty bitcoins.

She, being incredibly wealthy and generous, wants to send one hundred and one bitcoins to me (Rustie).

To start off, she first breaks open the one hundred (100) UTXO and makes that an input for the transaction to me.

However, she recognizes that she doesn’t yet have enough in the input, so she breaks open her next UTXO worth fifty (50)…

and makes that a second input for the transaction.

The transaction now currently has two inputs, one worth one hundred (100) and one worth fifty (50), and one output worth one hundred and one (101) to me.

What about the remaining 49 bitcoins that were originally Gloria’s? Where do those go? To make sure that Gloria can spend these bitcoins at a later date, she makes a second output to herself known as a change UTXO, or another piggy bank, containing all the remaining unspent bitcoins from the inputs.

] This way, she can give one hundred and one (101) of her one hundred and fifty (150) bitcoins to me and keep her remaining forty nine (49) even though she doesn’t have UTXOs which sum up to exactly the amount she wants to spend.

From here, if I’m equally generous and want to give that remaining amount to Derrick, I can just make my new UTXO an input into a different transaction,…

the output of which will be Derrick’s new UTXO.

This is how Bitcoin effectively keeps track of individual transactions and prevents anyone from spending incorrect amounts of bitcoin.

Demo: UTXOs