Chapter 4
Understand what happens when making a Bitcoin transfer, including inputs/outputs, UTXO, change, and how transaction fees are calculated.
14 minutes|Pascal Hügli|Published 2024-05-14|Updated 2024-06-13
Bitcoin transactions are arguably the most crucial part of the bitcoin system, as they are the thing that it actually processes. Any user can initiate a transaction, which is then propagated on the network, validated by full nodes, and finally added onto the Bitcoin blockchain, which is nothing but a globally distributed ledger of transactions.
Remember, a blockchain is a record of who owns what, and when. Therefore, a transaction tells the network that the owner of a given bitcoin value has authorized a transfer of this value to another owner. As Bitcoin units are transferred from one address to another, an immutable trace of ownership is created.
Technically, there are no bitcoins. While we usually speak of Bitcoin units or bitcoins to make sense of what is happening when making a transaction, in reality there are neither of these.
Bitcoin is exclusively based on ledger technology, which we've explained here. That ledger is constantly recording the history of transactions, by keeping track of the inputs and outputs of those transactions.
As a result, you and anyone else can browse and check every transaction that has ever been recorded on the Bitcoin blockchain, and get a complete overview of all the owners of bitcoins.
A Bitcoin transaction is made of two key elements: inputs and outputs.
Inputs represent debits from a Bitcoin address, or in other words the amount of BTC that is being sent in a transaction.
Outputs can be seen as credits to a Bitcoin address, or in other words the amount of BTC that is being received in a transaction.
To make a transaction, inputs are obviously needed in order to create outputs. But Bitcoin being a chain of transactions, the input of a transaction is always the output of a previous transaction.
Practically speaking, an input takes the spendable outputs of one or several past transactions in order to carry out a new transaction, thereby creating further outputs that can be spent again in the future.
Those spendable outputs from previous transactions are called UTXO, which means "unspent transaction output".
While the inputs of a given transaction are UTXOs from one or several previous transactions, the outputs of that given transaction will become the UTXOs of its recipient.
We can therefore say that UTXOs are the fundamental building blocks of Bitcoin transactions.
UTXOs being by definition unspent, they become eligible to serve as inputs for a future transaction. For all intents and purposes, we can say that bitcoin units are displayed in a UTXO. Therefore, a user's Bitcoin "balance" is the sum of all the UTXOs of his wallet.
In order to know the UTXOs that a given user is entitled to spend, the user's wallet scans the Bitcoin blockchain's UTXO set, which consists of the total amount of all known UTXOs on the network. Only if the wallet can find enough UTXOs that add up to the amount that the user wants to send will the wallet create a transaction with these UTXOs as inputs.
When a UTXO is spent, the respective Bitcoin transaction delivering this UTXO ensures that the UTXO will become spendable again by the recipient.
Interestingly enough, spending Bitcoin works in a similar way to transactions in cash. If you buy something that costs 9 euros with a banknote of 10 euros, you will receive 1 euro back as change.
Bitcoin works the same way: if the UTXOs used as inputs for a transaction are larger than the amount being transferred, the sender will receive the difference back as change.
Because of the design of Bitcoin, a UTXO has to be consumed in full when used, it cannot be split. That is why change must be generated in the outputs of a transaction.
For example, if you have 0.6 BTC worth of UTXOs and want to send 0.5 BTC to someone else, the transaction will consume 0.6 BTC but send you back 0.1 BTC.
This mechanism has scared many new Bitcoin users, who saw most of their Bitcoin balance disappear after making a transaction, only to see the right amount appear a moment later.
This happens precisely because enough UTXOs must be sent to cover the desired transaction amount, and the difference is returned.
Since all of this happens in a single transaction, which takes time to be processed and confirmed by the Bitcoin blockchain, it explains why you don't see your change return immediately on your address: it needs to be verified by the network before reappearing.
When you send Bitcoin to somebody else, the transaction needs to be signed to be approved. This means that the UTXOs that the transaction needs to use must be "unlocked" by the private key that controls them. That's what happens when you click the "Send" button in a Bitcoin wallet: the app uses your private key to generate a signature for the transaction.
As such, each transaction contains the signature used to approve it, which is the proof of ownership for the amount of bitcoin spent in that transaction.
That signature can be independently validated by anyone reading the Bitcoin network. In a sense, we can say that spending Bitcoin equals to signing a Bitcoin transaction, which will transfer a number of bitcoins from an address to another.
This signature design is how Bitcoin owners can prove by cryptography that they own a certain amount of bitcoin on a given address.
Note that a signature doesn't necessary require the transfer of bitcoins, it can also be used to sign a message. Some Bitcoin wallets provide an interface for this, which allows to input a string of text, run it through a mathematical formula in combination with the private key, and return an output string that confirms your control over an address.
Now that you have signed a transaction and initiated the transfer of some bitcoins to another address, let's look at what happens next.
First, the transaction is broadcast to the full nodes near you, which then relay the transaction to more full nodes until it has reached the entire network, like a wave.
Once done, the full nodes start their verification job. They check that you have the sufficient balance to make the transaction, they check your signature and whether you are trying to double spend, and they check that the transaction complies with all the other network's rules.
After the transaction has successfully passed this verification step, it is added to the mempool (a kind of waiting room for unconfirmed transactions) where it will wait to be picked up by a miner who will include it in a block.
When the transaction has been included in a block that has been successfully mined, the new block is then propagated to the network and verified by the full nodes. Once done, the transaction is now confirmed. Yay!
Adding one block to the blockchain requires solving a highly complex mathematical problem, and reversing it is equally difficult. Logically, reversing more blocks gets exponentially complex and computing intensive, which is why the more blocks that have come to pass after your transaction's block, the more secure it will be.
Therefore, each block that passes after your transaction represents 1 extra confirmation to it. That's why if you check your transaction on a block explorer, you will see its number of confirmations increase over time.
Confirmations are used by many apps as a way to determine whether they consider the transaction certain enough or not. For example, if you pay for something with bitcoins, the payment app will only consider the payment successful if a certain number of confirmations has been reached.
Because Bitcoin has no central entity that processes transactions and maintains its ledger, there must be an incentive for someone to do that task. As you know from our previous chapter on Bitcoin's network, that job is done by the miners. While they are paid with block rewards, they are also paid in transaction fees.
A transaction fee is paid by the sender of a Bitcoin transaction to its miner, and the amount of that fee basically tells the miners how much the sender is ready to pay for them to process that transaction.
Since mining is a profit-driven activity, miners usually choose the transactions waiting in the mempool with the highest fees. In theory, it could therefore be possible to release a zero-fee transaction on the Bitcoin network, but in practice it would never make it into the blockchain and remain pending forever.
Fees for Bitcoin transactions are a market driven by supply and demand. Supply is the available capacity of miners to process transactions, and demand is the number of transactions that users submit to the network. Therefore, the cost of making a Bitcoin transaction is always evolving based on the current level of utilization of the network.
When making a transaction, the wallet app automatically suggests a fee amount that should make the transaction be processed in less than an hour. Of course, depending on how urgent is the transaction, the user can always manually choose a higher or lower transaction fee. The higher the fee, the greater the chance that the transaction will be chosen by miners for the next block.
To check the current level of transactions fees on the Bitcoin network, go to mempool.space and look at the "Transaction fees" section:
The costs that you see there are displayed in sat/vB, meaning how many satoshis (1 BTC = 100,000,000 satoshis) are required to pay per byte of data consumed by the transaction.
For instance, if a transaction of 100 bytes is submitted with a fee of 20 sat/vB, the total cost will be 100 x 20 = 2,000 satoshis, or 0.00002 BTC.
The number of bytes consumed by a transaction depends on multiple factors. Typically, the number of UTXOs required to make one transaction will largely influence its cost. A transaction that uses 2 UTXOs or a transaction that uses 100 UTXOs will have a radically different cost. That's why a transaction of 10 bitcoins could potentially have a smaller fee than a transaction of 2 bitcoins.
Block explorers are the web browsers of the blockchain. They allow you to see in real time the transactions taking place on the network, and the detail of each address. The most used one today for Bitcoin is mempool.space, which we've mentioned several times in this article.
Being able to read it is very important, it will allow you to independently verify the balance of your wallet, its history of transactions and what happened in detail with each one of them.
For this example, we picked a random transaction from mempool.space, here is how it looks like:
In the transaction section, you first see the transaction hash (its unique identifier) and the number of confirmations. It also shows you the timestamp, which is when the transaction was mined, which miner processed the block in which the transaction was included, and the detail of the fee paid for the transaction.
This diagram gives you a visual way to understand the inputs and outputs of the transaction. The branches on the left show all the inputs, and on the right you see three outputs: the transaction fee (the smallest branch), the change (the middle branch) and the amount that was actually transferred (the largest branch).
This table shows you on the left side all the inputs of the transaction, which all came from the same address (it is not always the case). On the right side you can see the change that was sent back to the same address, and then the main amount (0.1 BTC) transferred to another address.
The main interest here is to see how much data was consumed by the transaction, which is used to determine its fee.
UTXO, meaning "unspent transaction output", are the amounts of bitcoins that an address has received and that are available for spending. The balance of a Bitcoin wallet is therefore the sum of its UTXO.
To send bitcoins, the transaction uses as many UTXOs from your address as required to reach the desired amount. Since each UTXO must be used in full, it's common to use more than the desired amount. The difference is returned to the wallet as change as soon as the transaction is confirmed.
Sending and receiving bitcoin is done through Bitcoin wallet applications, such as Bridge Wallet. You will find more info about them in our article on the different types of crypto wallets.
Bitcoin wallets have a receiving as well as a sending button. When you click on the "Send" button, the wallet will ask you to provide the recipient address, either by pasting it or by scanning it QR code. It will also ask you the amount to send, and if your Bitcoin balance is sufficient you will be able to send the transaction.
Most wallets will also offer advanced settings, where you can manually modify the price you are willing to pay for the transaction. If you don't know how to choose that amount, don't modify it and keep the wallet's default value.
When you click on the "Receive" button of your Bitcoin wallet, it will show you the Bitcoin address that you can share with people wanting to send you Bitcoin.
You can either share your written address, usually a string of 26 to 35 characters long consisting of numbers and letters, or share the address in the form of a QR code.
On average, a block of Bitcoin transactions is mined every 10 minutes. If your transaction has enough fees to be chosen by the miners for the next block, it will therefore take a few minutes. If the fee is too low, it can take hours or even days.
If a transaction has been pending for too long, you can try to speed it up by increasing its fee with the Child Pays For Parent (CPFP) technique. To do so, make a new transaction with any amount left on your wallet but with a significantly higher fee (you can estimate it here), and send it to yourself. Please note that it will work in certain cases, but not always.
It is not possible to cancel a Bitcoin transaction that has been confirmed. You can't cancel an unconfirmed transaction either, but you can try to replace it with a transaction with a higher fee in order to speed it up.
Go to mempool.space and search the transaction by entering its ID in the search field, or by entering the sender or receiving wallet address.
The size of a Bitcoin block is limited to 1 MB of data, the number of transactions it contains therefore depends on their weight. As of today, Bitcoin blocks contain between 2,000 to 4,000 transactions.
About the author
Pascal is a moderator, debater and lecturer at the Zurich University of Applied Sciences in Business Administration (HWZ). He advises the bank Maerki Baumann in a mandate as Crypto Investment Manager. As an analyst for the German-language newsletter Insight DeFi, he aims to inform the general public competently and concisely about the events and opportunities of the new decentralized world of Bitcoin and Co. He is also the author of the book Ignore at your own risk: The new decentralized world of Bitcoin and blockchain.
Subscribe to our newsletter and get the next chapters delivered straight to your mailbox.
Subscribe