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.
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.
Why this design
- 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.
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.
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?