UTXO Unspent Transaction Output

Apr 28, 2024 1:13:57 AM

What is Unspent Transaction Output?

UTXO, Unspent Transaction Output is how Bitcoin manages its coins. To better understand this, let’s think about how we can store information about how much money a person owns. Perhaps the most natural choice would be to keep a database containing each person’s balance. For example, Alice has 10 coins would be the type of information kept in the database. When Alice sends 2 coins to Bob, her balance will decrease by 2 coins, while Bob’s balance will increase by 2 coins.

Some blockchains, such as Ethereum, Solana and Neo, work exactly this way, keeping track of each account’s balance. But that’s not how Bitcoin works. There is no notion of account or balance in Bitcoin, only coins. At first, this may seem strange, but the truth is that we are used to this form of money. When we want to know how much money we have in our wallet, we count how many bills and coins we have.

Using coins is one of the oldest ways of handling money. Historically, salt, shells, metals, even large stones have been used to represent value. Bitcoin uses its own coins, which are also known as UTXOs. The difference is that such coins are not stored in your wallet, but in the Bitcoin database. What you keep in your wallet is the key to being able to claim ownership of some of these coins.

Bitcoin as a Coin-Creating Machine

Bitcoin can be thought of as a large bank, which is actually a machine for creating and transforming coins. Every 10 minutes on average, a new coin is created, currently worth 6.25 bitcoins. This is the mining process, and this newly created coin is given to the miner, the person responsible for keeping the database up to date and secure. All coins created and not yet spent (hence the name Unspent Transactions) are available in Bitcoin, and can only be spent by the person who has the right private key.

Bitcoin’s protocol stores information on all unspent coins (UTXOs) as well as their owners (private key holders). When someone wants to spend a coin (UTXO), he/she can. All he/she needs to do is sign a request with his private key, thus proving he owns that coin, and tell the protocol how he/she wants to spend that UTXO.

A Bitcoin Transaction Example

Let’s see how a bitcoin transaction takes place. Imagine that Alice wants to send 12 bitcoins to Bob. Let’s also say that Alice has 3 UTXOs, in the values of 2, 7 and 8 bitcoins. An alternative for Alice to make this transaction is to spend 2 of her UTXOs, the 7 bitcoin and 8 bitcoin ones. As they are being spent, they will no longer be UTXO. But the money does not disappear. If 15 bitcoins are being spent, 15 new bitcoins must be created. The most logical thing is to create a new 12 Bitcoin UTXO, which will be now owned by Bob, and a new 3 Bitcoin UTXO, which will be owned by Alice.

Note that the Bitcoin transaction is very similar to how we transact with banknotes and coins. Alice is handing Bob 15 bitcoins and receiving 3 bitcoins in change. The difference is that banknotes come with fixed values, whereas Bitcoin coins can have any value. And instead of paying Bob directly, she pays the protocol, which redirects the amount to Bob and the change to her.

This is one of the simplest transactions in Bitcoin. Users can do whatever they want with their UTXOs. They can break them into smaller UTXOs, combine smaller amounts into a larger UTXO, send any amount of bitcoins to multiple people in a single transaction, etc. The protocol doesn’t care what you do with your UTXOs, and you can even send them to nobody, which in practice means you’re burning money. Unlike in many countries, this is not illegal. And the miners don’t mind either, as long as you leave them a small tip (in bitcoins) within each transaction.

With the exception of the UTXOs that are burned, every UTXO is associated with a private key, through its pair: the public key. This has to do with asymmetric cryptography or public-key cryptography. But the most important thing to understand is that only in possession of the private key related to the public key indicated in the UTXO, it is possible to spend such UTXO. If by chance the owner of the UTXO loses the private key, that UTXO can never be spent. It will be lost forever.

UTXOs in Other Blockchains

Other blockchains besides Bitcoin use this same UTXO model. Examples are Litecoin and Bitcoin Cash. The old version of Neo, currently called Neo Legacy, also used UTXOs. Nowadays, however, with the implementation of smart contracts, most blockchains use an account-based mechanism. Each model has its advantages and disadvantages.

One of the major disadvantages of the UTXO model is that the blockchain needs to store information on all UTXOs, which can be costly and require a large database. Furthermore, to know the total balance that a private key can handle, one must find all the UTXOs that this private key has, and add them together. In the accounts model, to know the total balance of an account, just look for this information in the database. It’s much simpler.

The UTXO model, however, also has advantages. You don’t need to keep information about every account. In the accounts model, if an account has made a single transaction with the blockchain, its balance needs to be stored forever. Another advantage is that it is possible to track the entire history of a coin, which can be very useful in applications that go beyond finance, such as supply chain.

With the emergence of smart contracts, the account model has been used more often, as it works best on so-called general purpose blockchains such as Ethereum and Neo. However, the UTXO model still has a long life ahead of it, especially in more purpose-built blockchains.