Unspent Transaction Output: Bitcoin UTXO model explained
If you’ve been in the crypto space long enough, you most likely heard about the term UTXO, which is short for “Unspent Transaction Output“, and you probably wonder what the hell is this thing and what does it have to do with Bitcoin?
In this article, we will try to explain it so you can have a basic understanding of the UTXOs, how does they work and how it improves the digital currency.
What is an unspent transaction output (UTXO)?
Unspent transaction outputs, or UTXOs for short, are a fundamental component of Bitcoin’s transaction model. In simple terms. UTXOs represent the amont of Bitcoin a user holds, not as a balance, but as outputs from previous transactions that haven’t been spent.
When a user decides to make a new transaction, he takes one, or combines more than one UTXOs (we will come to this later) and reference these unspent outputs as Inputs in the transaction, “spending” them in the process.
All existing UTXOs at a given point in time is called a UTXO set.
UTXO set is like a big digital jar containing all the unspent coins (or UTXOs) of every Bitcoin user. It’s a record of the ledger of all the coins that haven’t been used yet. When you want to know how much Bitcoin you or anyone else has, you can look in this jar and count the coins related to that specific address. Bitcoin nodes keep track of the set in order to determine how many coins exist and who can spend them. This is crucial of preventing the double spend problem.
This UTXO model ensures transaction security, transparency, and integrity within the decentralized Bitcoin network.
How are UTXOs created?
Every bitcoin transaction consists of inputs and outputs.
To create an input, a transaction must consume an existing UTXO, creating a new UTXO and so on.
You may ask: “But, if old UTXO have to be destroyed in order to create a new UTXO, how are UTXOs created in the first place?”
A Coinbase transaction is the first transaction in every block.
Approximately every 10 minutes on average a new block is created. Every new block consists of fresh newly mined bitcoins which is called a block subsidy. Currently the block rewards are 6.25 BTC + cumulative fees of all the transactions in the block.
The coinbase transaction is the only transaction that is valid without an input and can create new, one or more outputs, which means that it DOES NOT require Bitcoin to be spent from previous transaction.
This is how new UTXOs are created.
How does the UTXO model works?
At the heart of most cryptocurrencies lies the concept of a transaction, which is the mechanism to transfer value between participants in the system. Let’s break down the basics:
In the context of cryptocurrencies like Bitcoin, a transaction denotes the movement of coins from one party to another.
Each transaction is a digital message, signed cryptographically, and then broadcast to the network for verification and eventual inclusion in a block.
A cryptocurrency transaction cosists of Input and output.
Transactions in cryptocurrencies like Bitcoin are not like typical account debits in traditional banking. Instead, they reference past transactions.
An input in a transaction specifies which previous transaction’s output will be used to fetch the coins for the current transaction.
This is crucial because it establishes a chain of ownership for the coins.
Each blockchain transaction creates outputs, which can be thought of as “containers” of cryptocurrency coins with a specific value.
These outputs will then serve as potential inputs for future transactions. An important aspect to note about outputs is that they are indivisible. If you want to use just a portion of an output, you’d have to “spend” the whole output and then return the change to yourself.
Let’s give an example, using gold.
Imagine you receive a 10 ounces gold coin, but you want to buy a car that costs 3 ounces of gold. What you would have to do is, melt the 10 ounces gold coin, you initially received and make two coins. One coin of 7 ounces and one 3 ounces. You will then pay for the car with the 3 ounces coin and keep the 7 ounces coin for you.
Bitcoin is similar. If someone sends you 10 Bitcoin to your wallet, what you get is one UTXO worth 10 bitcoin.
Now, lets say you want to buy a car worth 3 Bitcoin. You would need to ‘break’ that 10 Bitcoin UTXO and spend only portion of it. The way you do it is buy putting it into a transaction as an Input. With the tansaction, you can divide those 10 Bitcoin however you want and send it to as many different addresses as you like.
This is where the concept of “change” comes in.
To spend 3 BTC for a car, you take the 10 BTC as an input to the transaction and make 2 new outputs; one as a payment (3 BTC) and another (7 BTC) as change back to one of your own addresses.
Here is an example of how the transaction would look like.
Note: For simplicity we will not include the transaction fees for the blockchain network.
Bob’s bitcoin sitting in one of his addresses has been split into two pieces. The Car dealer’s address has recieved 3 Bitcoins and Bob gets back the change of 7 Bitcoins.
Let’s look at one more example.
Lets imagine that three of your friends (we will call them John, Dan and Alice) decided to send you some Bitcoin.
John sends you 0.2 BTC
Dan sends you 0.5 BTC
Alice sends you 0.01 BTC.
In your wallet you will see that you have a total sum of 0.71 BTC, but what you actually have are 3 different unspent transaction outputs (UTXOs).
UTXO1 : 0.2 BTC
UTXO2 : 0.5 BTC
UTXO3 : 0.01 BTC
If you now want to pay 0.6 BTC to someone, your transaction would take the 0.2 + 0.5 bitcoin UTXOs and put them together, (leaving the 0.01 bitcoin UTXO alone). The transaction would have two outputs: 0.6 BTC as the payment and 0.1 as change. It will look like this:
After the transaction is complete, your wallet will have a 0.1 bitcoin UTXO and 0.01 bitcoin UTXO. Two “coins” with total balance of 0.11 BTC.
Privacy Benefits of the UTXO Model
Bitcoin users can hold each UTXO separately by storing every UTXO in a different and unique new bitcoin address.By doing so, users can hide the connection between their UTXO from the public eye and make it really difficult for outside people to know which UTXOs belong to which users.
Comparing UTXO with Account Balance Model
The Unspent Transaction Output (UTXO) model and the Account/Balance model are two predominant methods of representing and managing funds in the world of cryptocurrencies. Both models come with their distinct advantages and trade-offs.
UTXO Model (e.g., Bitcoin)
Privacy: Since every transaction produces new UTXOs, tracking the flow of coins can be more complex.
Parallel Processing: UTXO-based transactions that aren’t related can be processed in parallel, which can offer scalability advantages.
Transparency: Every coin in the UTXO model has a traceable history, making the lineage of transactions clear.
Security: The stateless nature of UTXOs can offer certain security benefits, as attackers can’t simply change a balance; they would need to tamper with specific transaction outputs.
Complexity for Users: UTXO management can sometimes be confusing for end-users, especially concerning “change” addresses.
Efficiency: UTXO models might require more space and computational power, particularly as the set of UTXOs grows.
Account Balance Model (e.g., Ethereum)
Simplicity: This model is much like traditional banking, where accounts have balances that increase or decrease. It’s intuitive and straightforward.
Space Efficiency: Generally requires less space than the UTXO model, as it doesn’t need to store individual outputs.
Smart Contracts: Account-based models, especially in platforms like Ethereum, facilitate the creation of complex smart contracts.
Parallel Processing: Transactions from the same account need to be processed in sequence to prevent double-spending, which can pose scalability challenges.
Privacy: All transactions and associated balances are directly linked to account addresses, potentially offering less privacy compared to UTXO models.
While the UTXO model emphasizes privacy, security, and the clear lineage of coins, it can be more complex and resource-intensive.
The account model, on the other hand, provides simplicity akin to traditional banking systems and is more space-efficient.
The choice between the two depends on the specific goals and intended applications of the cryptocurrency in question.
We hope that, after reading the article, you now have better understanding of what UTXOs are, how they actually work and why they are important to Bitcoin.
If you want to learn more about Bitcoin, you can visit our Bitcoin Hub, where you can find a lot of useful articles.