If we wanted to summarize how Bitcoin works in the simplest possible way, we could say that it records transfers of value between different addresses by storing the details of those transfers on the blockchain. A transaction is therefore the most important piece of information contained in the blockchain.
What is a Bitcoin transaction?
In its most basic form, a Bitcoin transaction represents the transfer of funds (denominated in bitcoin) from one Bitcoin address (the sender) to another (the recipient). Every transaction is permanently recorded on the blockchain, ensuring the immutability and transparency of every exchange.
To better understand how a Bitcoin transaction works, we can compare it to the way paper checks operate.
Imagine, for a moment, a world in which there are no banknotes or coins of fixed denominations, and everyone makes payments by endorsing checks.
In such a system, making a payment would require exchanging and transforming those checks. The sender would take one or more checks made out in their name to a bank, endorse them over to the bank, and receive a newly issued check payable to the recipient. If the total value of the original checks exceeded the payment amount, the bank would also issue a separate "change" check back to the sender. The original checks would then be canceled, and only the newly issued checks would remain valid for future payments.
While such a process would be cumbersome and impractical in the real world, it becomes much simpler and more efficient in the context of digital money.
Bitcoin transactions work in exactly this way.
When someone owns bitcoin, they do not actually hold "coins." Instead, they control UTXOs (Unspent Transaction Outputs)—outputs from previous transactions that have not yet been spent. To spend some of these bitcoin, the owner must create a new transaction. This new transaction consists of two parts:
- An INPUT section, which collects one or more UTXOs, each accompanied by the digital signature of its rightful owner, authorizing (or unlocking) it for spending.
- An OUTPUT section, where new UTXOs are created to replace the ones that have been spent. These new outputs are assigned to their new owners, identified by their respective Bitcoin addresses.
It may happen that the amount of bitcoin we want to transfer is smaller than the total value available in our UTXOs. Imagine Bob has only a single "check" worth 50 BTC, but he only wants to pay Alice 0.5 BTC.
In this case, Bob cannot simply tear off a portion of the check corresponding to the amount he wants to send. Instead, he must spend the entire digital "check"—that is, the entire UTXO. After sending 0.5 BTC to Alice, the remaining 49.5 BTC must be sent somewhere. In Bitcoin, that destination is known as the change address.
As a result, the transaction's outputs will typically contain two entries: one transferring 0.5 BTC to Alice, and another returning the remaining 49.5 BTC to a new Bitcoin address controlled by Bob. This mechanism ensures that Bob retains control of his unspent bitcoin after the transaction is completed.
How is a Bitcoin transaction verified?
For a transaction to be accepted by the network and successfully transfer value, it must be valid and pass a series of protocol checks.
In fact, every Bitcoin transaction must satisfy more than 40 validation rules before it can be considered valid by the network.
Some of the most important checks include:
- Every input UTXO must be authorized by its rightful owner through a valid digital signature.
- The digital signature must correspond to the public key (or Bitcoin address) that controls the UTXO, proving that the spender is authorized to spend those funds.
- The transaction itself must be properly signed by the sender, demonstrating authorization to spend all of the referenced inputs.
- The total value of the new output UTXOs cannot exceed the total value of the input UTXOs. In other words, a transaction cannot create bitcoin out of thin air. Any difference between the total input value and the total output value is interpreted as the transaction fee, which is collected by the miner who includes the transaction in a block.
Important: According to the Bitcoin protocol, there is no central authority responsible for validating transactions. Instead, every participant in the network independently performs these checks in their own interest.
A useful analogy is receiving a paper check: each of us would naturally verify that the check is genuine before accepting it. Similarly, every Bitcoin node independently verifies the validity of every transaction it receives before relaying it to other nodes.
How is a transaction confirmed?
A transaction being valid is not enough for it to have effect. It must also be accepted by the network and permanently recorded on the blockchain.
This happens when a miner selects the transaction, includes it in a candidate block, successfully mines that block, and the block is accepted by the rest of the network.
The lifecycle of a Bitcoin transaction can be summarized as follows:
- The transaction is created and digitally signed by the user using their Bitcoin wallet.
- The transaction is broadcast to the Bitcoin network, where the first node that receives it performs a full validation.
- If the receiving node determines that the transaction is invalid (i.e., it violates the Bitcoin protocol), it rejects and does not relay it. If the transaction is valid, the node forwards it to its peers, allowing it to propagate throughout the network.
- Once validated, the transaction enters the mempool, the network's waiting area for valid but unconfirmed transactions awaiting selection by miners.
- One or more miners select the transaction from their mempool to include it in a candidate block, typically prioritizing transactions that offer higher fees.
- Sooner or later, a miner successfully mines a block containing that transaction.
- The transaction is removed from the mempool, since it has now been included in the blockchain.
- The transaction is recorded in the latest block of the blockchain, at which point it is said to have one confirmation.
- Each subsequent block adds another confirmation to the transaction. Once it reaches six confirmations, it is widely considered to be final, as reversing it would require an extraordinary amount of computational power and is considered economically impractical.