Blockchain Fundamentals #2: What are UTXOs?

Andrew
Byzantine
Published in
4 min readMay 28, 2018

--

Like many complex subjects, the Crypto world is composed of various concepts that are difficult to understand at first. The UTXO is no exception. Seemingly straightforward, I found this idea particularly tricky to get. Analyzing a UTXO in isolation only begs additional questions — soon leaving you wondering what the heck you’ve been reading for the past two hours.

Let’s start with a simple definition.

Unspent Transaction Outputs (UTXO) are all the spendable outputs for a given address available to be used in new transactions.

There’s a conceptual dependency here which is understanding how transactions work. Let’s use Bitcoin to analyze this.

Transactions (Inputs & Outputs)

It’s important to remember that in Bitcoin, you never actually hold something called “Bitcoin”. You don’t own a unique token that lives somewhere on the internet. Instead, you own the “rights” to move Bitcoin from one place to another. Admittedly, even this analogy breaks down quickly since no Bitcoin is ever actually “moved”. This was hard for me to grasp when I first started learning about Cryptocurrencies. I kept envisioning a digital file of some sort moving from one machine to another.

What actually happens is a form of double-entry bookkeeping. Each transaction contains one or more “inputs” which can be thought of as “debits” to a Bitcoin account. Those inputs turn into spendable “outputs” for the eventual recipient(s).

I highly recommend watching the below video by professor Donald J. Patterson to gain a better understanding of how the Bitcoin transaction process works.

To quickly summarize, all transactions (except the coinbase) have both inputs and outputs. Inputs are where the money came from and outputs are where the money is going. Unless you’re a miner receiving newly created Bitcoin, every output sent to you will contain one or more inputs indicating where the money originated from. If you keep following this trail back you’ll eventually arrive at the the first transaction of a given block — the coinbase transaction.

So all Bitcoin transactions therefore have the following constraints:

  1. Every input must be valid and not yet spent
  2. The transaction must have a signature matching the owner of the input
  3. The total value of the inputs must equal or exceed the total value of the outputs

The UTXO

Alright so let’s say you create a new Bitcoin address. At this point your balance would be zero since the address won’t have any inputs or outputs traceable to it. Now let’s say you’re friends with Alice who owns 10 BTC. She wakes up one morning, feeling particularly philanthropic, and decides to send you one Bitcoin. Woo! Let’s pause at this point and analyze some important things that are happening now.

First, the one BTC that Alice sends is actually considered a UTXO for you. This is because it’s an unspent output controlled by the private key of your wallet address. Unspent because you haven’t sent it to another address yet — output because it came from Alice. The one BTC represented a UTXO for Alice prior to sending it to you, and a spent transaction output for someone else further down the chain.

Second, when an output is marked as spent this means the previous owner who once maintained the “right to spend”, no longer does. The Bitcoin network is continuously creating and removing UTXOs with each transaction. You can think of each UTXO creating a different “state” of the overall Bitcoin blockchain. This state allows every user in the network to keep track of who owns the right to spend BTC.

Third, the inputs you receive don’t “mix” together like they would with physical coins. For example, if Alice decided to send you another BTC, you would now have two separate spendable outputs assigned to your address. These two spendable outputs are UTXOs for you.

Finally, when you send BTC to another person your wallet software will look for one or more unspent outputs — assigned to your address — and use them as inputs to the recipient. If a single UTXO isn’t large enough to satisfy the demand of the input amount, then the wallet will use a second, a third, etc until the total is greater than or equal to the amount your sending. This is key to understanding the nature of UTXOs. Sometimes this “total” can be much larger then the needed input amount. This is because the Bitcoin protocol requires that any UTXO must be completely spent if it’s used to fulfill the total input requirements. You can’t divide UTXOs. The difference is then sent back to you as “change” during the the transaction. Interestingly enough, this “change” is represented as a newly created UTXO assigned to you.

Conclusion

I’ve found that understanding UTXOs is easier when described and not defined. It’s the kind of concept that becomes clearer as you begin adding context to it.

If you see anything wrong with my analysis please let me know in the comments! Cheers!

--

--

Andrew
Byzantine

Software Engineer currently studying Blockchain at Byzantine https://byzantine.studio