Transactions enable you to transfer bitcoin (abbreviated as BTC) from one user to another on the Bitcoin network. You need a wallet to initiate a transaction. Wallets are a mechanism to securely generate virtually infinite numbers of addresses that belong to a user. A phone number enables you to make or receive calls on a telephone network. Similarly, an email address enables you to send or receive emails on the Internet. Just like that, a Bitcoin address allows you to send or receive bitcoin on the Bitcoin network. Unlike a phone number or an email address, you have access to virtually an unlimited number of addresses through a Bitcoin wallet.
Bitcoin transactions were modeled after cash transactions. A Bitcoin transaction is similar to a cash transaction in the following ways:
- peer-to-peer: when you use cash to pay someone in the real world, the transaction happens directly between you and the person you are paying. This is different from credit/debit card transactions, where other banks and institutions act as intermediaries to facilitate the transaction.
- settlement finality: cash transactions are settled instantly unlike credit/debit card transaction which could take days to settle. While not instant, Bitcoin transactions take on average 10 minutes to settle.
- permission-less: you do not need anyone’s permission to be able to do transactions on the Bitcoin network.
Say, you went to a grocery store and at checkout your total came out to be $70.39. When you give the cashier a $100 bill, you will expect to get some change back, $29.61 in this case. Lets break down this cash transaction into pieces. Your wallet had a $100 bill. Lets label that as input because that is used to source funds for your cash transaction. If there is an input, there must be an output as well. In this case, it follows logically that there are two outputs:
- $70.39 that you pay to the grocery store and is now owned by them
- $29.61 that you get back as change that you own
So, you see, how one input of $100 created two outputs that each belong to different parties, the grocery store and yourself respectively. Normally, you would take the $29.61 change that you got back and put it in your wallet. Later on, that particular output can be used as an input for another transaction because this output of $29.61 has not been spent (unspent).
Bitcoin transactions work in a similar fashion. Say, you have 1 BTC in your wallet and you want to pay someone 0.2 BTC for their services. If we apply the same input/output labels as before, we get:
- 1 BTC
- 0.2 BTC owned by who you paid
- 0.8 BTC is the ‘change’ output that you will own
Now, a natural question that arises is, when can an output be used as an input? For example, the 0.8 BTC change output that will be created as a part of the transaction above, when can we use that as an input for another transaction?
When a transaction ‘settles’, the input that was used to source funds for the transaction is converted into the outputs. From the cash example, the transaction is settled once:
- the cashier takes your $100 bill and checks to make sure its not counterfeit thereby accepting your $100 bill
- the cashier then gives you $29.61 back as change
The $100 input has now been changed into two outputs. The cashier’s acceptance of your $100 bill and your acceptance of the change amount are physical actions that settle the cash transaction. However, Bitcoin is like digital cash, we can’t take any physical actions to settle a Bitcoin transaction. So, how in the world is a Bitcoin transaction settled then? How are inputs to a Bitcoin transaction converted
Bitcoin mining is like a competition where special purpose computers (called miners) race to solve a complex computational problem. Miners try to guess a solution to the problem and the first one to solve it gets to add a new block of transactions to the blockchain. This process requires a lot of computational power and rewards miners with newly created bitcoins for their work. As more miners join in, the problems get harder, making it more challenging to mine bitcoins. Imagine this like a group sharing a pizza. As more people join in, the slices shrink—everyone gets a smaller piece.
Fragments of Value (UTXOs)
When a miner finds the right answer to a puzzle, they tell the Bitcoin network about the new block they have made. All the transactions inside this block are then seen as “confirmed” and become official in the Bitcoin record. Consider our earlier example again. You had one input worth 1 BTC in your wallet. You wanted to make a payment of 0.2 BTC to someone. Since you only had one input, that input needed to split into two outputs. The first one worth 0.2 BTC is sent to the person you are paying. The second one worth 0.8 BTC is sent back to you. When that transaction is confirmed in a block, it settles. Now, the person you paid officially owns the 0.2 BTC, and you own the 0.8 BTC. The network forgets about the 1 BTC you had before and only sees these new amounts. Your 0.8 BTC is what is left from that transaction and it’s called an Unspent Transaction Output (UTXO). Later, you can use this UTXO as an input into another transaction.
Spending bitcoin creates new UTXOs
Using the 0.8 BTC UTXO generated from the prior transaction, lets say you initiate another transaction. Within this transaction, 0.15 BTC was sent as payment to someone else, while the remainder, 0.65 BTC, came back to you. This 0.65 BTC becomes your sole UTXO after the completion of this transaction making it the only bitcoin you possess. We can clearly see now, how new UTXOs are created as a result of a transaction and how some of those UTXOs that we own can serve as inputs for future transactions. Is this the only way to create UTXOs though? What if someone sends us some bitcoin, what happens then?
Receiving bitcoin creates new UTXOs
When someone sends us bitcoin, it generates a new UTXO within our wallet. The example below shows a transaction which was created by someone else. They used a UTXO worth 0.5 BTC to create two new UTXOs. The 0.3 BTC UTXO is paid to you and the 0.2 BTC goes back to their wallet as change.
After the above, your wallet will have the two UTXOs indicated in the diagram below.
Since the total balance of a wallet is the sum of all UTXOs in the wallet, you now own:
0.65 BTC + 0.3 BTC = 0.95 BTC
To sum up, Bitcoin transactions function similarly to cash transactions in terms of transferring value. However, Bitcoin’s uniqueness lies in its utilization of Unspent Transaction Outputs (UTXOs). These UTXOs, comparable to the cash in your wallet, represent fragments of Bitcoin value, which may be split and/or combined and reorganized with each transaction. The Bitcoin ledger serves as a record, meticulously tracking the ownership of these UTXOs.