7 min read

Bitcoin UTXOs: Explained for Beginners

Bitcoin UTXOs: Explained for Beginners

💡
Note: New to this website? Check out our first article What is Bitcoin? as it contains useful context for many of the ideas discussed below!

Enjoy! 🧡

🍊 Found this valuable?

🎓 Ready to Test Your Knowledge?

Subscribe for free so you don't miss our next article!


You might be surprised to learn that UTXOs are the real currency of bitcoin!

If you own bitcoin, what you actually own are a bunch of UTXOs. In this article, we'll explain what UTXOs are and how they work at a beginner level.


What is a UTXO?

UTXO stands for:

U = Unspent
TX = Transaction
O = Output

UTXOs are like 'chunks' of bitcoin. They are outputs from past bitcoin transactions, which can then be used as inputs in future bitcoin transactions.

The UTXO Lifecycle

Similarities Between UTXOs and Cash

It's easy to think of UTXOs in cash-like terms: if Bob wants to deliver $10 of value to his friend Mallory, he can do this by handing her a $10 bill:

  1. Bob picks up a $10 bill (input)
  2. Bob hands the $10 bill to Mallory (output)

Similarly, if Mallory wants to deliver 0.4 BTC to her friend Alice, she can do this by creating a transaction:

  1. Mallory selects one of the UTXOs she owns worth 0.4 BTC (input)
  2. Mallory designates Alice as the recipient of 0.4 BTC (output)

How UTXOs Differ From Cash

With physical cash, the $10 bill Bob picked up (input) is the same physical object as the $10 bill he handed to Mallory (output), and that $10 bill can continue to be spent and re-spent over and over again. However, the 0.4 BTC Mallory selected (input) is completely destroyed once she decides to transfer its value to Alice! In its place, a brand new 0.4 BTC (output) is created and assigned to Alice.

But... why?

The answer is that bitcoin involves the exchange of pure information without a trusted third party. And, well... it's pretty easy to copy information! So, if people could just re-use the same bitcoins over and over the way we re-use paper bills with physical cash, people could counterfeit bitcoin easily.

Information is easy to copy

Rules to Remember

Bitcoin UTXOs follow simple rules, chief among which is that each UTXO (i.e. each 'chunk' of bitcoin) can only be spent once.

Here are three basic rules to remember about bitcoin transactions and UTXOs:

  1. All transaction inputs must be UTXOs.
  2. UTXOs cannot be partially spent. When spent, a UTXO is destroyed.
  3. The sum of inputs must always equal the sum of outputs (plus the miner fee).

Now let's see how these rules apply in an actual bitcoin transaction.

Example Transaction

Below is a sample transaction in which Bob pays Alice 1.75 BTC.

Bob pays Alice 1.75 BTC and receives 0.049 BTC back as change. The remainder (0.001 BTC) is the miner fee.

Bob's Wallet

On the top left, we can see Bob owned a total of 5.74 BTC before his payment to Alice took place. This number is what Bob would have seen on the front page of his wallet application. Behind the scenes, Bob's wallet software actually sums together all his UTXOs from past transactions to come up with this 5.74 BTC figure.

On the top right, we can see Bob now owns a total of 3.989 BTC after his payment to Alice. This is because Bob paid 1.75 BTC to Alice and 0.049 BTC back to himself as change. The remaining 0.001 BTC was leftover to be scooped up as a fee by a miner, resulting in a total of 1.751 BTC in expenditures. (For more on the bitcoin mining process, see our previous article.)

5.74 - 1.751 = 3.989 BTC

Alice's Wallet

Similarly, on the bottom left we can see Alice owned 0.2 BTC before the transaction. In her case, this balance was entirely the result of one past transaction. We know this because she only had one UTXO.

On the bottom right, we can see Alice now owns 1.95 BTC after the transaction. This is because Bob paid her 1.75 BTC.

0.2 + 1.75 = 1.95 BTC

Nodes (computers) check bitcoin transactions to make sure they follow the rules

The Transaction

The actual bitcoin transaction between Bob and Alice contains inputs and outputs. But how are these inputs and outputs chosen?

Recall the three simple rules listed above. Nodes enforce these rules (and more):

  1. All transaction inputs must be UTXOs

    Checking Bob's transaction inputs, we can see the two inputs were both taken from his existing set of UTXOs. His wallet selected {1.5 BTC + 0.3 BTC}.
  2. UTXOs cannot be partially spent. When spent, a UTXO is destroyed.

    Looking at the transaction details, we can see both the above inputs were spent entirely, and two new outputs were created as a result.
  3. The sum of inputs must always equal the sum of outputs (plus the miner fee).

    The above inputs sum to 1.8 BTC. We can work backwards to figure out what his outputs should be.

    We know Bob wants to send Alice 1.75 BTC, but he also wants to pay a miner fee to ensure his transaction gets added to a block. The miner fee is determined based on the current fee market, which Bob's wallet application will check for him. Miners are fetching around 0.001 BTC on average at the time of Bob's transaction, so his wallet automatically uses that as the miner fee.

    After accounting for Alice and the miner, Bob has 1.8 - 1.75 - 0.001 = 0.049 BTC leftover. This remaining amount should be returned to Bob as change.

    Bob's outputs sum to 1.779 BTC. Adding the 0.001 BTC (fee) = 1.8 BTC.

Assembling Transactions

Thankfully, you don't need to worry about messing up the above steps (unless of course you're a crazy person with a paper wallet––but that's a topic for another article). All the work of assembling a transaction and making sure it has valid inputs and outputs is handled for you through automation by your wallet software.

What Users See

When you submit a bitcoin transaction, here's what you see:

  1. You open your wallet (usually an app on your phone)
  2. You scan a QR code from the person you want to pay
  3. You specify how much bitcoin you want to send

And... voila! You just spent bitcoin. It's that simple.

What Really Happens

When you submit a bitcoin transaction, here's what really happens:

  1. You open your wallet (usually an app on your phone)
  2. You scan a QR code from the person you want to pay (e.g. Alice)
  3. Your wallet software translates the QR code into a bitcoin address
  4. You specify how much bitcoin you want to send (e.g. 0.5 BTC)
  5. Your wallet software checks all your available UTXOs and picks some combination of UTXOs that, when summed together, is larger than the amount you want to send plus a miner fee
  6. Your wallet software builds a bitcoin transaction using the UTXOs it found above as inputs (e.g. 0.35 and 0.3). It also writes new outputs into the transaction, assigning them to each party as appropriate:

    Input #1 = 0.35 BTC
    Input #2 = 0.3 BTC
    ------------------------
    Total Inputs = 0.65 BTC

    Output #1 = 0.5 BTC to Alice
    Output #2 = 0.149 BTC back to you (as change)
    ------------------------
    Total Outputs = 0.649 BTC

    Leftover = 0.001 BTC to the Miner (miner fee)
  7. Next, your wallet software signs the transaction using your private key. This mathematically proves that you are the sole owner of the UTXOs being used as inputs (the 0.35 BTC and 0.3 BTC above), which means you are authorized to spend them.
  8. At this point, your wallet broadcasts the transaction to the bitcoin network for all bitcoin nodes to see.
  9. Bitcoin nodes that receive the broadcasted message check your transaction to make sure it follows all the protocol rules and is considered valid. This includes checking to make sure the signature is valid and that your transaction inputs are unspent.
  10. Once validated, nodes add your transaction to the mempool, where it waits to be scooped up by a miner into a block on the blockchain.
  11. Once a miner adds it to the blockchain, your transaction is effectively settled (Note: technically it is considered best practice to wait for a few more blocks (3-5) to be mined on top of the block containing your transaction before considering it truly irreversible).
  12. Once the miner's block is added to the blockchain, the miner receives the fee leftover from the transaction as part of the coinbase transaction.

For more on bitcoin mining, check out our other article here!


Where are UTXOs Stored?

Short answer: the bitcoin blockchain.

Longer answer: UTXOs are just values locked to addresses on the bitcoin blockchain. So, if you "own bitcoin", it means you have private keys that can unlock specific UTXOs from addresses and use them as inputs in transactions.

Since UTXOs are destroyed once they're spent, you can think of all the existing bitcoin in circulation as the set of all UTXOs that are "still alive". This is known as "the UTXO set", and it's stored by all bitcoin full nodes so they can ensure new transactions don't attempt to double-spend coins.

UTXOs and Privacy

Since every UTXO is a 'chunk' of bitcoin resulting from a prior transaction, that means every UTXO can be linked to a previous transaction. And since the bitcoin blockchain is public and viewable by anyone with an Internet connection, that means if you own bitcoin, your very own UTXOs can be traced!

Therefore, the only way to remain private with bitcoin is to remain anonymous. That's why many bitcoiners urge users to avoid centralized exchanges that force people to give up private information about themselves before transacting, such as name, age, date of birth, photo ID, etc. These requirements are known as "KYC" (short for: "Know Your Customer").

Giving up this information to a company and then sending bitcoin to your personal wallet is equivalent to telling that company which bitcoin UTXOs are yours. Once they know which UTXOs are yours, they can also give this information to other companies or governments and compromise your privacy entirely.


Share on Twitter


🍊 Found this valuable?

🎓 Ready to Test Your Knowledge?