An unspent transaction output, better known as a UTXO, is an important concept in the world of blockchain. The name might seem a little confusing but the concept itself is not hard to understand. This post will explain everything you need to know about UTXO.
UTXO Blockchains vs. Other Blockchain Protocols
An unspent transaction output is the output of a transaction that a user receives and is able to spend in the future. This is true because, as the name suggests, it is the unspent output of a transaction. It's a way of organizing a blockchain's ledger such that no funds are spent twice, avoiding the double spending problem.
Broadly speaking, the UTXO model is one variety of blockchain protocol. While there's no mention of UTXO in the Bitcoin white paper, the UTXO model was first developed by Satoshi Nakamoto when the Bitcoin blockchain was first published. The original Bitcoin script relies heavily on UTXO to check whether or not a particular wallet has sufficient funds to execute a requested transaction.
For example, if Bob submits a transaction to the network asking to send 3 coins to Alice, the network needs to know that Bob's wallet has at least 3 coins in it first. If Bob's wallet doesn't have at least 3 coins in it, then it should be impossible for him to send 3 coins to Alice.
Since Bitcoin uses the UTXO model, all forks of Bitcoin use the UTXO model, too. Forks of Bitcoin forks also use UTXO. Zcash is a fork of Bitcoin with zero knowledge privacy features added in to the protocol and Komodo was originally a fork of the Zcash blockchain. So, by extension, Komodo is a Bitcoin fork and uses the UTXO model.
However, not all blockchains that use the UTXO model are Bitcoin forks. Monero, the well-known privacy coin, is one prominent example. The Monero Development Team uses an implementation of the UTXO model established by Bitcoin, but it is not a Bitcoin fork. Monero has its own protocol known as ring signatures. Cardano is another great example of a blockchain that uses UTXO but not the Bitcoin protocol.
It's also important to state that not all blockchains use the UTXO model. The Ethereum blockchain, for instance, uses a system known as the "account-based model" or the "balance-based model." This model is akin to each individual wallet having a ledger of its own. Using basic arithmetic, coins and tokens are added and subtracted from each wallet to provide a final balance after every transaction.
Lastly, note that a blockchain's protocol is not to be confused with its cryptographic hash function, such as SHA-256 or Equihash, nor is it to be confused with its consensus rules, such as Proof of Work or Proof of Stake.
UTXO Explained With A Simple Analogy
Each and every UTXO is like a single fiat coin or a single fiat bill. If you have $45 in cash, you must have more than one bill because there’s no such thing as a forty-five dollar bill. So while you have $45 dollars in your wallet, you may have any number of combination of bills— UTXO— sitting in your wallet.
In this simple example, you could have any of the following combinations of fiat bills:
- Forty-five $1 bills
- Nine $5 bills
- Four $10 bills and one $5 bill
- Two $20 bills and five $1 bills
And so on. There are many more combinations of bills that add up to $45 but you get the idea. In each case, you have exactly $45 despite the fact that you have a different number of bills in each scenario.
The same is true of UTXO. Although you see a single balance when you log in to your crypto wallet, you may have one or many UTXO sitting in your wallet. These UTXO vary in size but when added together, the sum is equal to the total balance of your wallet.
Now let’s take our analogy one step further. When you buy an item in cash, you might not be able to provide the exact amount of money needed to pay for it. For example, let’s say you buy a cup of coffee for $3.50. You have $45 in your wallet but, chances are, you don’t have exactly $3.50 to pay for the coffee.
Instead, you’ll need to overpay with one (or several) of your bills and then receive a little bit of money in return. You might pay for the coffee with four $1 bills, in which case you would receive two quarters in return. Or you might pay for the coffee with a $20 bill, in which case you would get one $10 bill, one $5 bill, one $1 bill, and two quarters in return. You get the idea.
The same thing happens when you send cryptocurrencies. Let’s say that you have a total of 740 KMD coins. Imagine that your balance is in the form of 3 UTXO: one UTXO in the amount of 320 KMD, a second of 215 KMD, and a third of 205 KMD.
If you want to send a smaller quantity of KMD to a different address, your wallet must send at least one whole UTXO to complete the transaction. Just as you can’t pay for a $5 item by tearing a $10 bill in half and handing one piece to the cashier, you cannot send half of a UTXO to complete a crypto trade. You must send the entire UTXO and then receive change.
Let’s imagine you want to send 30 KMD to a friend. You would have to send one of your UTXOs (320, 215, or 205 KMD) to complete the transaction. Your friend would receive his single UTXO of 30 KMD. You would receive a new, smaller UTXO in the amount of 290, 185, or 175 KMD, depending on which UTXO was sent.
What happens if you want to send your friend 350 KMD coins? Essentially the same thing would take place, except this time you would need to send two full UTXO in order to complete the transaction. Your friend would still receive his 350 KMD and you would receive a new UTXO in return (70, 175, or 185 KMD coins, depending on which two UTXO were sent to execute the payment).
The Differences Between Fiat Bills And UTXO
The analogy above is accurate enough to give you a solid understanding of the concept of a UTXO but it’s not perfect. The analogy breaks down in several ways.
First, the examples above are not exactly accurate because you would need to pay the transactions fees for executing your trade. When you send a certain sum of money to a different address, the new UTXO that you receive in return will be the amount of the original UTXO minus both the amount of currency you’re sending away and the amount of fees you must pay.
New UTXO = (sum of original UTXO) - (sum of currency sent to a different address) - (transaction fees for that particular blockchain)
Transaction fees vary from blockchain to blockchain, and can even vary on the same blockchain at different times. On AtomicDEX, Komodo's decentralized exchange, transaction fees are only 0.15% of the full amount of the transaction. The trader who accepts an offer posted on the orderbook (the ‘Alice’ in the trade) must pay the fee.
Here's a visualization of how a series of transactions would work on Komodo.
The second way in which our previous UTXO analogy breaks down is that fiat bills are fixed in value. In other words, fiat bills are limited to the value that governments choose to print in.
In the USA, the only bills in existence are: $1, $5, $10, $20, $50, and $100. In nations that have adopted the Euro, the only bill denomination are: €5, €10, €20, €50, €100, €200 and €500. This ignores coins but the point remains: you cannot create bills in any amount you please. The value of each bill is predetermined.
This is not true of UTXO. A UTXO can come in any amount whatsoever. In practice, this offers several important benefits. For one, it provides a lot more flexibility than fiat currency. It’s possible to have 1 million KMD in a single UTXO, instead of the thousands of fiat bills that would be required to hold the same amount in cash for a fiat currency.
Blockchain developers have the opportunity to write code that can optimize the way in which small denominations of cryptocurrency are packaged into “bills” (UTXO). This means that a team of developers can work together to keep the data weight of the blockchain manageable. The better the digital-wallet developers, the more efficient the sizes of the UTXO that get created. More efficient UTXO generation means minimal data weight and optimal processing speeds.
However, blockchain tech does have one limitation when compared to fiat: the number and quantity of UTXO in each person’s digital wallet must be recorded.
As a result of most blockchains’ protocols, which require that all transactions take place on a public ledger, the only time UTXO can be assembled or disassembled into larger or smaller sizes is at the moment when you are involved in a transaction on the public blockchain. If you do not send or receive funds, the quantity and amount of the UTXO you hold in your wallet cannot be adjusted.
In reality, this is but a minor drawback. The number and sizes of UTXO in your wallet will naturally vary over time. You may have many smaller UTXOs that make up your full balance, or sometimes you might just have one large UTXO that comprises all of it.
From the perspective of an end user, it is ordinarily not necessary to understand the concept of a UTXO at all. The balance you see in your crypto wallet is the amount of crypto you have, regardless of the number and value of UTXO that make up that sum.
This might have you wondering: why are UTXOs important at all? Great question! The next section will explain.
When And Why Are UTXO Important?
The idea of a UTXO is crucial for understanding two of Komodo Platform’s most important technologies.
First, Komodo's Lead Developer, jl777, found a way to develop UTXO-based smart contracts. This is an enormous breakthrough because it makes Bitcoin-protocol coins capable of supporting Turing complete smart contracts and decentralized applications. These UTXO-based smart contracts are language agnostic and allow every UTXO to have a unique consensus mechanism. It's a truly revolutionary development.
For those who may not be familiar, atomic swaps are peer-to-peer crypto trades that do not require a middleman or third party. There are no escrow services, proxy tokens, or other centralized accounts. Rather, atomic swaps are trades of cryptocurrency directly between users’ wallets.
It is important to understand UTXO before understanding how atomic swaps work because users must have at least 2 UTXO each in order to successfully complete an atomic swap. If you’d like to learn more about how they work, check out this blog post on atomic swaps.
To get all the latest updates from Komodo, join the monthly email list. On the first Friday of every month, you'll receive a newsletter with information about all of the most important developments from the previous month. You can also join the Komodo Discord server to chat with other community members and the Komodo team.