— —
Follow on X
LESSONS

Transactions and UTXOs

Bitcoin has no account balances. It tracks unspent outputs. A payment unlocks whole outputs and creates new ones, with change back to you.

6 MIN READ
A transaction unlocks inputs, creates outputs including change, and the difference is the fee.
LEVEL · Intermediate
IN THIS LESSON · 2 OF 9
BY THE END YOU WILL BE ABLE TO ANSWER
  • What is a UTXO?
  • Why does a transaction usually have a change output?
  • What are the inputs of a transaction?
  • A transaction spends inputs of 0.5 and 0.3 BTC and creates outputs of 0.6 and 0.1995 BTC. What is the fee, in BTC?

Then prove it: a 3-question quiz · a challenge. The lesson marks itself complete at 100%.

After this lesson you can: read a transaction as inputs, outputs and change.

Bitcoin does not keep balances. It keeps a set of unspent transaction outputs, or UTXOs: discrete chunks of bitcoin, each locked to an address. Think of them as notes and coins of arbitrary size rather than a number in an account.

Two columns: an account with a balance versus a set of unspent outputs of different sizes.
Accounts versus outputs. Bitcoin has no balances, only unspent outputs locked to keys.

Spending

To pay someone, your wallet selects UTXOs as inputs, unlocks them with signatures, and creates new outputs: one to the recipient and, because you cannot split a note, one change output back to an address you control. The sum of inputs minus the sum of outputs is the fee, claimed by the miner.

Example: you hold a 0.010 BTC output and want to pay 0.004. The transaction consumes the whole 0.010 and creates 0.004 to them and 0.0059 to you, leaving 0.0001 as fee.

Transaction diagram: one input of 0.010 BTC becomes 0.004 to the recipient and 0.0059 change, with 0.0001 as the fee.
The example as a diagram: the whole 0.010 output is consumed; two new outputs are created; the gap is the fee.

Why this design

Diagram showing a transaction where a single 25 BTC input is split into a 1 BTC and a 24 BTC output.
A 25 BTC output spent whole: 1 BTC to the payee, 24 BTC back as change.Image: learnmeabitcoin.com

  • Verification is simple. A node only needs to know the current UTXO set to check any transaction: do these inputs exist, are they unspent, do the signatures match, do outputs not exceed inputs.
  • Parallelism and privacy. Outputs are independent; a wallet can use many addresses.
  • No accounts to freeze. There is nothing to lock; only outputs and the keys that unlock them.

Diagram showing a chain of transactions where the new transactions spend the outputs of previous transactions.
Every input is a previous output; the chain of ownership is the chain of transactions.Image: learnmeabitcoin.com

Things that surprise people

  • Your balance is the sum of your UTXOs; a wallet with many small ones pays more in fees to spend them, because the transaction is bigger.
  • A transaction is valid only when every input is unspent. Once mined, those inputs are gone from the set forever.
  • Transactions have no "from address" in the way email does; they have inputs, which reference earlier outputs.
How the Bitcoin network works · RiverWatch on YouTube ↗
MINI CHALLENGEFind the fee

A transaction spends inputs of 0.5 and 0.3 BTC and creates outputs of 0.6 and 0.1995 BTC. What is the fee, in BTC?

BTC
CHECK YOURSELF
1/3 What is a UTXO?
2/3 Why does a transaction usually have a change output?
3/3 What are the inputs of a transaction?
pick an answer for each question

SOURCES

  1. Bitcoin: A Peer-to-Peer Electronic Cash System (Satoshi Nakamoto, 2008)
  2. Learn Me A Bitcoin: How does Bitcoin work?
Progress is saved in this browser only.