Unspent Transaction Output (UTXO) is the “balance” that the sender gets back to the wallet after the transaction. This method ensures that the user has money in the account and protects the network from a “double spending” attack.
This technology of sending transactions is implemented in Bitcoin and other coins (for example, in Komodo).
Note, when Bitcoin was created users had to manually configure the sending of “balances” to their wallets. In addition to filling in the recipient address, it was also necessary to indicate the address to which the unspent bitcoins would come. If the wallet address was entered incorrectly, then the sender permanently lost his coins.
Modern Bitcoin wallets do this job for the user: now it’s enough to specify only the recipient’s address. The process of sending cryptocurrencies has become simpler and less risky thanks to UTXO.
Now we define the principle of operation of UTXO. This can very easily be explained by the example of fiat money. Each UTXO is a single bill or coin. Imagine you have $ 75. No one denomination would be equivalent to a given value. You can have, for example, the following variations of $ 75 bills:
There are many more combinations, but the idea is clear. In any of the variations, you end up with exactly $ 75.
The same thing happens in UTXO. When you look at your balance, you see only one specific number, for example, 101 BTC. But this is only the outer shell – several UTXOs are hiding “under the hood” of your balance. For example, you may have four UTXOs of 25 BTC each, two UTXOs of 50 BTC or UTXOs of 38, 18, 40 and 5 BTC. Specific variations do not matter – in the end, they must match the balance on the account.
Now let’s look at a specific example of how this principle works with UTXO in transactions. For example, you want to buy a new car. As a crypto enthusiast, you do not see any other options for yourself, except for “Lamborgini”. Let’s say it costs 35 BTC. But your wallet has only UTXO equal to 18, 5, 38 and 40 BTC.
The network selects UTXO at 40 BTC and splits it into two others at a cost of 35 BTC and 5 BTC. 35 BTC are sent to the seller, and the remaining 5 you get back to your wallet, of course, minus the network commission.
However, it is not a fact that 100% will be chosen by UTXO at a cost of 40 BTC – the network can also send two UTXOs at 18 and 38 BTC, and you will receive 21 BTC.
A transaction can be formed with any combination, and the user has no control over this process.
The principle of operation of UTXO in the Bitcoin network is as follows:
It is also important to consider that the user will receive a “balance”, from which the transaction sending fee will already be deducted. You can calculate how many bitcoins a user will receive in the following formula:
New UTXO = sent UTXO – transaction amount – commission
Using the above example, let’s see how much you get back (let’s say that the network fee is 1 BTC):
New UTXO = (18 BTC + 38 BTC) – 35 BTC – 1 BTC = 20 BTC
As a result, 20 BTC will be returned to your wallet address.
The main advantages of this method are three.
The first is a higher degree of confidentiality (compared, for example, with an account-based transaction model like Ethereum). The approach implemented in UTXO complicates the task of establishing a connection between addresses. So, the user can use different addresses to send bitcoins from his account, mixing different UTXOs. Now, this property is called pseudo-anonymous, since methods for tracking payments in the Bitcoin network have already been developed. However, in combination with other technologies that aim to ensure confidentiality (for example, the zk-SNARK protocol), UTXOs are an appropriate transaction model.
The second advantage is the higher scalability. Transactions are processed in parallel since each UTXO comes from a separate input (Input) and is not tied to others. The network does not need to check the entire transaction history (as it does in the account-based transaction model), but simply check the specific UTXO using the Input bound to it.
From this, another advantage of UTXO follows the ability to work with cryptocurrency in “light” wallets. This is ensured thanks to SPV (Simplified Payment Verification) technology – a simplified payment verification, which was described in the original Bitcoin WhitePaper. SPV makes it possible to verify payments of a specific user, without taking into account the transactions of the rest. To do this, an incomplete node (namely, these are “light” clients) communicates with trusted and reliable complete network nodes and verifies a specific transaction based on their information.
However, the work of this protocol has its drawbacks. Firstly, this method is not compatible with smart contracts and dApps. It can be used only in those applications where each individual output is used by only one user. In applications that require at least two users to interact with one UTXO, this transaction model does not work. However, according to the Komodo team, their lead developer found a way to develop smart contracts based on UTXO. Besides, Komodo also uses UTXO on its atomic swap exchange platform.
The second problem is an increase in the size of blocks and, as a result, an increase in the volume of the entire blockchain. Full nodes store all UTXO transactions, and with the growth of the network, launching a full node becomes an expensive pleasure.
Now there is already a solution to this problem. The developers offer to store only part of the information about UTXO in RAM, and for the rest use more affordable disks (HDD or SSD). This approach to some extent increases transaction processing time since the nodes will have to go to several places when verifying transactions, but practice shows that even using this method, verification takes less than 10 minutes.
Besides, Bitcoin Core developers are constantly optimizing the protocol for more efficient transaction processing. And also do not forget about the technology of Segregated Witness (Segwit), which works on the principle of subscription data. It does not depend on the volume of UTXO in any way and, besides, makes payments cheaper (according to the developers of Bitcoin Core by 75%).