Skip to content
On this page

Lesson 3: Transactions & UTXOs - How Bitcoin Actually Moves

๐Ÿ”„ Intermediate โ€ข โฑ๏ธ 90-120 min โ€ข โš›๏ธ 300 Quarks

The Secret Behind Every Bitcoin Transaction

You've learned about keys and wallets. Now it's time to understand how Bitcoin actually moves from one person to another. Spoiler: It's not like sending an email or Venmo.

Bitcoin transactions work more like physical cash than digital bank transfers. You can't "send half a dollar bill"โ€”you have to spend the whole thing and get change back. Bitcoin works the same way with something called UTXOs (Unspent Transaction Outputs).

In this lesson, you'll learn:

  • How Bitcoin transactions really work under the hood
  • What UTXOs are and why they matter
  • Transaction inputs, outputs, and fees
  • How to read a real Bitcoin transaction
  • Why some transactions are faster/cheaper than others
  • The mempool and transaction confirmation

Ready to become a Bitcoin transaction expert? Let's dive in! ๐Ÿ’ธ

๐Ÿ“บ WATCH FIRST: Bitcoin Transactions Explained

๐Ÿ“บ Simply Explained: How do Bitcoin Transactions Work? (6 min)

The Big Idea: UTXOs (Unspent Transaction Outputs)

Forget everything you know about bank accounts. Bitcoin doesn't have "account balances." Instead, it tracks UTXOsโ€”individual chunks of Bitcoin that belong to you.

Think of UTXOs Like Physical Bills

Imagine your wallet has:

  • One $20 bill
  • One $10 bill
  • Three $1 bills

Total: $33

Now you want to buy something for $25. You can't just "send $25." You have to:

  1. Give the $20 and $10 bills (inputs)
  2. Receive $5 back as change (output)

Bitcoin works exactly the same way:

  • Your "balance" is actually a collection of UTXOs (like bills)
  • To spend Bitcoin, you use entire UTXOs as inputs
  • You create outputs for the recipient and yourself (change)
  • The difference between inputs and outputs = miner fee

Real Example

You have:

  • UTXO #1: 0.05 BTC
  • UTXO #2: 0.1 BTC
  • UTXO #3: 0.025 BTC

Total balance: 0.175 BTC

You want to send 0.08 BTC to a friend. Your wallet:

  1. Selects UTXO #2 (0.1 BTC) as input
  2. Creates output #1: 0.08 BTC to your friend
  3. Creates output #2: 0.0199 BTC back to you (change)
  4. Leaves 0.0001 BTC as miner fee

After the transaction:

  • UTXO #2 is spent (destroyed)
  • Your friend has a new UTXO: 0.08 BTC
  • You have a new UTXO: 0.0199 BTC
  • You still have UTXO #1 and #3 (untouched)

New balance: 0.05 + 0.025 + 0.0199 = 0.0949 BTC

Anatomy of a Bitcoin Transaction

Every Bitcoin transaction has three main parts:

1. Inputs (What You're Spending)

Inputs are references to previous UTXOs you own. Each input includes:

  • Transaction ID (txid) of the previous transaction
  • Output index (which UTXO from that transaction)
  • Signature (proof you own the private key)
  • Script (unlocking script to spend the UTXO)

Example:

Input:
  Previous TX: a1b2c3d4e5f6...
  Output Index: 0
  Signature: 304402207a8b9c...
  Amount: 0.1 BTC
Input:
  Previous TX: a1b2c3d4e5f6...
  Output Index: 0
  Signature: 304402207a8b9c...
  Amount: 0.1 BTC
1
2
3
4
5

2. Outputs (Where It's Going)

Outputs create new UTXOs. Each output includes:

  • Amount (in satoshis: 1 BTC = 100,000,000 sats)
  • Locking script (specifies who can spend it)
  • Address (recipient's Bitcoin address)

Example:

Output #1:
  Amount: 0.08 BTC
  Address: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
  
Output #2 (Change):
  Amount: 0.0199 BTC
  Address: 1YourOwnChangeAddress...
Output #1:
  Amount: 0.08 BTC
  Address: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
  
Output #2 (Change):
  Amount: 0.0199 BTC
  Address: 1YourOwnChangeAddress...
1
2
3
4
5
6
7

3. Metadata

  • Version: Transaction format version
  • Locktime: Earliest time/block transaction can be added
  • Size: Transaction size in bytes (affects fee)
  • Weight: SegWit-adjusted size metric

๐Ÿฐ DOWN THE RABBIT HOLE: The $500 Million Fee Mistake

In September 2023, someone made a $3 million fee mistake on a single Bitcoin transaction.

They meant to pay a $3 fee but accidentally paid $3,000,000 instead. How? They mixed up the fee field with the amount field.

What happened:

  • Input: 139 BTC
  • Output: 55 BTC
  • Fee: 84 BTC ($3M at the time)

The miner who found the block initially kept it, but after public pressure and realizing it was a mistake, they returned most of it.

The lesson: Always double-check your transaction details before broadcasting. Bitcoin transactions are irreversible.

๐Ÿ”— Read the full story โ†’

Transaction Fees: Why They Exist

Bitcoin miners don't work for free. They need incentive to include your transaction in a block.

How Fees Work

Fee = Total Inputs - Total Outputs

Whatever you don't explicitly send to an output becomes the miner's fee. This is why you need a change output!

Example:

  • Input: 1.0 BTC
  • Output to friend: 0.5 BTC
  • Output to yourself (change): 0.4999 BTC
  • Fee: 0.0001 BTC (10,000 sats)

Fee Rates: Sats per vByte (sat/vB)

Fees are measured in satoshis per virtual byte (sat/vB):

  • Larger transactions (more inputs/outputs) = higher total fee
  • Fee rate determines priority (higher rate = faster confirmation)

Current typical rates:

  • ๐ŸŒ Low priority: 1-5 sat/vB (might take hours or days)
  • โšก Medium priority: 10-50 sat/vB (next few blocks)
  • ๐Ÿš€ High priority: 100+ sat/vB (next block, ~10 min)

Fee calculation:

Transaction size: 250 bytes
Fee rate: 20 sat/vB
Total fee: 250 ร— 20 = 5,000 sats (0.00005 BTC)
Transaction size: 250 bytes
Fee rate: 20 sat/vB
Total fee: 250 ร— 20 = 5,000 sats (0.00005 BTC)
1
2
3

Why Fees Fluctuate

Fees change based on network demand:

  • High demand (bull market, NFT mints): Fees spike to 100+ sat/vB
  • Low demand (quiet periods): Fees drop to 1-2 sat/vB
  • Block space is limited: Only ~2,500 transactions fit per block
  • Miners prioritize: Highest fee rate transactions get included first

๐Ÿ’ก PRO TIP: Timing Your Transactions

Send Bitcoin during low-traffic times to save on fees:

  • โœ… Weekends (less trading activity)
  • โœ… Late night UTC (Asian/European markets closed)
  • โŒ Avoid: Monday mornings, major announcements, bull market peaks

Use mempool.space to check current fee rates before sending!

The Mempool: Bitcoin's Waiting Room

When you broadcast a transaction, it doesn't immediately go into a block. It enters the mempool (memory pool)โ€”a waiting area where transactions sit until miners include them.

How It Works

  1. You broadcast your transaction to the network
  2. Nodes validate it (correct signatures, sufficient funds)
  3. Transaction enters mempool of every node
  4. Miners select transactions with highest fee rates
  5. Block is mined (~10 min average)
  6. Your transaction is confirmed and leaves the mempool

Mempool Visualization

Think of the mempool like an airport:

  • Economy class (low fees): Long wait, might not get on next flight
  • Business class (medium fees): Reasonable wait, likely next few flights
  • First class (high fees): Priority boarding, next flight guaranteed

Mempool size tells you network congestion:

  • Empty mempool: Send with 1 sat/vB, confirm quickly
  • Full mempool (100+ MB): Need 50+ sat/vB to confirm soon

๐Ÿ“บ Visual Explanation: How Bitcoin Mining Works (5 min)

Transaction Confirmations: How Many Do You Need?

A confirmation means your transaction is included in a block. More confirmations = more secure.

Confirmation Levels

  • 0 confirmations (unconfirmed): In mempool, not yet in a block

    • โš ๏ธ Can be replaced or double-spent
    • Don't accept for large amounts
  • 1 confirmation: Included in latest block

    • โœ… Safe for small amounts (<$1,000)
    • Still technically reversible (rare)
  • 3 confirmations: 3 blocks deep (~30 min)

    • โœ… Safe for medium amounts ($1,000-$10,000)
    • Very unlikely to reverse
  • 6 confirmations: 6 blocks deep (~1 hour)

    • โœ… Standard for large amounts ($10,000+)
    • Considered "final" by most exchanges
    • Reversing requires massive mining power

Why 6? Satoshi Nakamoto recommended 6 confirmations as the threshold where reversing a transaction becomes economically impractical for an attacker.

๐Ÿฐ DOWN THE RABBIT HOLE: The Double-Spend Attack

Can you spend the same Bitcoin twice? Technically yes, but only if you control massive mining power.

How it works:

  1. You send Bitcoin to a merchant (Transaction A)
  2. Merchant sees it in mempool, ships product
  3. You secretly mine a competing block with Transaction B (same Bitcoin to yourself)
  4. If your block wins, Transaction A is invalid
  5. You keep the Bitcoin AND the product

Why it's nearly impossible:

  • You need 51% of network hash power (costs billions)
  • The longer you wait (more confirmations), the harder it gets
  • After 6 confirmations, you'd need to mine 6 blocks faster than the entire network

Real-world attacks:

  • Bitcoin Gold (2018): 51% attack, $18M stolen
  • Ethereum Classic (2020): Multiple 51% attacks
  • Bitcoin: Never successfully attacked (too expensive)

This is why Bitcoin's massive mining network is its security. The bigger the network, the more expensive attacks become.

Transaction Types

1. Standard Transaction (P2PKH)

Pay-to-Public-Key-Hashโ€”the original Bitcoin transaction type.

  • Address starts with 1
  • Most common, widely supported

2. SegWit Transaction (P2WPKH)

Segregated Witnessโ€”separates signature data to reduce size.

  • Address starts with bc1q
  • ~40% smaller = lower fees
  • Fixes transaction malleability

3. Taproot Transaction (P2TR)

Latest upgrade (2021)โ€”improves privacy and enables complex scripts.

  • Address starts with bc1p
  • Better privacy (all transactions look the same)
  • Enables Lightning Network improvements

4. Multi-Signature (Multisig)

Requires multiple signatures to spend.

  • Address starts with 3
  • Used for security (2-of-3, 3-of-5, etc.)
  • Common for businesses and cold storage

Reading a Real Bitcoin Transaction

Let's decode a real transaction from the blockchain:

Transaction ID: 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b

This is the famous Bitcoin Pizza transaction from May 22, 2010โ€”the first real-world Bitcoin purchase.

Details:

  • Inputs: 1 input (Laszlo Hanyecz's UTXO)
  • Outputs: 2 outputs
    • 10,000 BTC to pizza seller
    • Change back to Laszlo
  • Fee: 0 BTC (early Bitcoin had no fees!)
  • Size: 257 bytes
  • Confirmations: 800,000+ (deeply buried)

๐Ÿ”— View on blockchain explorer โ†’

๐Ÿ• DOWN THE RABBIT HOLE: Bitcoin Pizza Day

May 22, 2010: Laszlo Hanyecz paid 10,000 BTC for two Papa John's pizzas.

At the time: ~$41 worth of Bitcoin Today: $600,000,000+ ๐Ÿคฏ

Laszlo posted on BitcoinTalk forum:

"I'll pay 10,000 bitcoins for a couple of pizzas... like maybe 2 large ones so I have some left over for the next day."

A British man took the deal, ordered the pizzas to Laszlo's house, and received the 10,000 BTC.

Was it worth it? Absolutely! This transaction proved Bitcoin could be used for real-world commerce. Without pioneers like Laszlo, Bitcoin might never have gained traction.

Every May 22, the Bitcoin community celebrates Bitcoin Pizza Day ๐Ÿ•

๐Ÿ”— Read Laszlo's original post โ†’

Replace-By-Fee (RBF): Speeding Up Transactions

Sent a transaction with too low a fee? You can replace it with a higher-fee version.

How RBF works:

  1. Your original transaction sits in mempool (unconfirmed)
  2. You create a new transaction with the same inputs
  3. You increase the fee rate
  4. Broadcast the new transaction
  5. Miners replace the old one with the new one (higher fee = more profit)

Requirements:

  • Original transaction must signal RBF (BIP 125)
  • New transaction must have higher fee
  • Original transaction must still be unconfirmed

When to use:

  • Transaction stuck for hours/days
  • Network fees suddenly dropped
  • Urgent payment needs faster confirmation

Child-Pays-For-Parent (CPFP): Another Fee Boost

If you're the recipient of a stuck transaction, you can speed it up with CPFP.

How CPFP works:

  1. You receive a low-fee transaction (unconfirmed)
  2. You spend that UTXO in a new transaction
  3. You attach a high fee to your transaction
  4. Miners must confirm the parent (original) to confirm your child
  5. Your high fee incentivizes them to include both

Example:

  • Parent transaction: 1 sat/vB (stuck)
  • Child transaction: 100 sat/vB (your transaction)
  • Combined: 50 sat/vB average
  • Miner confirms both to get your high fee

Transaction Privacy

Bitcoin transactions are pseudonymous, not anonymous:

  • All transactions are public on the blockchain
  • Addresses aren't directly linked to identities
  • But blockchain analysis can trace patterns

Privacy Best Practices

  1. Use a new address for every transaction

    • Prevents address reuse tracking
    • Modern wallets do this automatically
  2. Avoid address reuse

    • Reusing addresses links all your transactions
    • Makes it easy to see your total balance
  3. Use CoinJoin for privacy

    • Mixes your transaction with others
    • Breaks the transaction graph
    • Tools: Wasabi Wallet, Samourai Whirlpool
  4. Run your own node

    • Don't leak your addresses to third-party servers
    • Full privacy and verification

Why This Matters for Gamers

When you win sats playing games on Bitcoin Arcade:

  1. Instant credits: Your winnings create UTXOs in your wallet
  2. Batch withdrawals: We combine multiple small UTXOs to save on fees
  3. Fee optimization: Withdrawals happen during low-fee periods
  4. Confirmation speed: Small amounts (1 conf), large amounts (6 conf)
  5. Transaction tracking: See your winnings on the blockchain

Understanding UTXOs helps you:

  • Know when to consolidate small UTXOs
  • Choose the right fee for withdrawals
  • Track your transaction confirmations
  • Understand why some withdrawals take longer

Key Takeaways

  • UTXOs are like physical billsโ€”you spend whole amounts and get change
  • Inputs reference previous UTXOs you own
  • Outputs create new UTXOs for recipients
  • Fees = Inputs - Outputs (leftover goes to miners)
  • Mempool is where unconfirmed transactions wait
  • Confirmations increase security (6 is standard)
  • Fee rates (sat/vB) determine confirmation speed
  • RBF and CPFP let you speed up stuck transactions
  • Privacy requires careful address management

๐ŸŽฏ Test Your Knowledge

โš ๏ธ ONE SHOT ONLY - STUDY UP!

You can only earn Quarks once per lesson. Take your time reviewing the material above before starting. You can retake the quiz as many times as needed, but Quarks are only awarded on your first perfect score!


โ† Previous: Keys & Wallets | Next Lesson: Mining & Proof-of-Work โ†’

Built with โค๏ธ for the Bitcoin community