Introduction
Cash has qualities people value. When you hold a $50 banknote, you can hand it directly to someone who accepts it. The payment can happen without a bank approving it or recording the purchase in your account history. That gives cash a degree of privacy and lets people transact directly.
Distance makes this harder. Cash works well when two people are in the same place. Paying someone across the country or across the world calls for a way to transfer value without delivering the banknotes yourself.
Banks and payment services made this possible through electronic records. The sender still has to cover the payment, whether by depositing cash, using an account balance, or arranging credit. The institutions involved check the payment instructions and keep track of what each party is owed.
Bitcoin introduced a different approach. It lets a network of independently operated computers maintain a shared transaction record that participants can verify. Its central challenge is preventing the same digital funds from being spent twice without relying on one bank or payment company to decide which payment counts.
This lesson explains that challenge and follows a Bitcoin payment from the sender’s wallet to the shared ledger.
What you’ll learn
- How paying with cash differs from paying through a bank account.
- What double-spending is and why a digital payment system needs rules to prevent it.
- How Bitcoin uses a shared record that participants can check independently.
Lesson
When you hand a cashier a $20 banknote, the store takes possession of it.
You can’t hand that same bill to another cashier while the first store
has it. Paper cash is useful when people can meet. Paying a bill from
home or buying something from a store across the country calls for a way
to pay without delivering the bills to the recipient yourself.
Banks and payment services already made remote payments possible
before Bitcoin. You still had to cover the amount. You could hand cash
to a money transfer service or pay from funds in a bank account. The
service used electronic records to get the money to the person far away,
who could receive it in an account or, depending on the service, pick it
up in cash. When you pay online from a bank account, the payment system
checks whether the payment is authorized and updates the relevant
records. A ledger is a record of payments, balances, or
obligations. The bank and the other institutions in the payment system
maintain those records. If you try to spend the same available $20
twice, the payment system uses its records and rules to decide what can
go through.
What problem was
Bitcoin trying to solve?
Bitcoin asked whether people could send and receive digital payments
without relying on a bank or payment company to decide which
payments count. To do that, it needed a way to prevent
double-spending, which means trying to spend the same
digital funds more than once.
A digital payment instruction can be copied, and someone can sign two
different instructions that try to spend the same funds. A signature can
show that a payment was authorized. The network also needs to check
whether those funds were already spent in the payment history it
accepts.
How Bitcoin’s ledger and
payments work
Bitcoin’s ledger is the blockchain, a public history
of transactions grouped into blocks. Each block references the previous
one. Full nodes independently check that blocks and transactions follow
Bitcoin’s rules. From the history they accept, nodes track which pieces
of bitcoin are still available to spend. Each piece is called an
unspent transaction output, or UTXO.
Your wallet tracks the outputs you can spend and adds them up to show
your balance.
Example · Paying a store in
bitcoin
Suppose your wallet can spend one output worth 100,000
satoshis. A satoshi is the smallest unit of bitcoin recorded on
the blockchain. The store asks for 60,000 satoshis, and
your wallet uses 1,000 satoshis as a fee.
- Build the payment. Your wallet selects the
100,000-satoshi output as the input. It creates a new output of 60,000
for the store and another of 39,000 as change for you. The difference
between the inputs and outputs is the 1,000-satoshi fee.
- Sign and broadcast. Your wallet signs the payment
with the key needed to authorize the spend. It sends the signed
transaction to the network and keeps the private key secret.
- Check and relay. Nodes check the transaction,
including whether you authorized the spend and whether the input is
available in their current view of the ledger. Nodes that accept the
transaction into their local pool of pending payments can relay it. At
this point the payment is unconfirmed.
- Include it in a block. A miner can select the
transaction for a proposed block and use proof of work to compete to add
that block. Full nodes independently check the block. When it becomes
part of the chain a node accepts, the original 100,000-satoshi output is
marked spent, and the store’s payment and your change become new unspent
outputs.
- Count confirmations. Inclusion in the accepted
chain gives the payment its first confirmation. Each additional block
built on top adds another. More confirmations make it less likely that a
competing valid history will replace the block containing the
payment.
If you sign a second payment using that same 100,000-satoshi output,
both signatures could be valid. Only one transaction can spend
that output in the same accepted history. That’s why Bitcoin
needs both signatures and a shared ledger.
Worked example · One
$20 payment, three ways
Imagine you have enough for either a $20 grocery purchase or a $20
household bill.
| Paper cash |
Once the grocery store has your $20 banknote, you no longer have that
bill to hand to anyone else. |
| Bank payment |
The payment system checks the account records and applies its rules
to the two requests. |
| Bitcoin |
If both payment instructions try to spend the same Bitcoin output,
nodes check them against the accepted history. Only one can spend that
output in that history. |
Practice quiz
Select one answer per question.
Answer key and explanations
A. The sender still had to cover the payment.
The bank or transfer service handled getting the money to the recipient
from a distance.
B. Someone can authorize two conflicting
payments. Nodes still check which transaction, if any, spent the funds
in the history they accept.
C. Bitcoin uses a shared transaction history
that participants can check independently.
A. The transaction uses the whole original
output. The store’s payment and your change are separate new outputs.
The fee is the difference between the input and the new
outputs.
Further reading: Bitcoin’s
original paper
Technical references: Bitcoin
transactions and Bitcoin’s
block chain.
Sign in with Discord to take this quiz and earn your badge.