The UTXO: An Elusive, yet Fundamental Concept

All Bitcoin-based software relies heavily on a technology called the “utxo,” short for Unspent Transaction. This technology was invented in the original Bitcoin protocol. Yet despite the technology’s age, even the most active of cryptocurrency users rarely know what utxos are or why they exist.

To better understand utxos, let us first examine the language of a common user when describing how much cryptocurrency money they have and how they perceive those funds. We will therefore need to understand the concept of “satoshis,” the way a blockchain handles the collection and distribution of funds, and how we utilize these core technologies when trading on AtomicDEX.

Comparing the Utxo to Fiat Money

Let us assume a cryptocurrency user, whom we name Charlie, has $10,000 in his physical wallet. Naturally, when Charlie thinks about the amount of physical (or “fiat”) money he has, he says to himself, “I have $10,000.”

However, there is no such thing as a $10,000-dollar bill. Instead, Charlie actually has a collection of smaller bills stacked together. For instance, he could have a stack of $100-dollar bills, the total of which equals $10,000 dollars.

If Charlie goes to purchase an item that costs $1, and he only has $100-dollar bills in his wallet, to make his purchase he will take out a single $100-dollar bill and give it to the cashier. The cashier then breaks that $100-dollar bill down into a series of smaller bills. The cost for the item, $1, remains with the cashier, and the cashier then provides change—perhaps in the form of one $50-dollar bill, two $20-dollar bills, one $5-dollar bill, and four $1-dollar bills.

Charlie now thinks to himself, “I have $9,999.” Specifically, however, he has ninety-nine $100-dollar bills, a $50-dollar bill, two $20-dollar bills, one $5-dollar bill, and four $1-dollar bills.

We emphasize that not only does he not have ten thousand $1-dollar bills, he also does not have one million pennies ($0.01). Furthermore, because pennies are the smallest divisible unit of value in Charlie’s wallet, we could point out that each bill is a collection of its respective units of pennies. For instance, a $1-dollar bill in Charlie’s wallet we could describe as, “a bill that represents a collection of one hundred pennies and their value.”

Understanding Cryptocurrencies and Their Utxos

A Satoshi is The Smallest Divisible Unit of a Cryptocurrency

Continuing with our explanation of utxos, we next need to understand the concept of “satoshis.” The name “satoshi” is derived in honor of Satoshi Nakamoto, author of the original Bitcoin whitepaper. By convention in the cryptocurrency community, one satoshi is equal to one unit of a coin at the smallest divisible level. For instance, 1 satoshi of Bitcoin is equal to 0.00000001 BTC.

Let us suppose now that Charlie has 9.99000999 BTC (Bitcoin) in his digital wallet. Assuming Charlie correctly understands the concept of satoshis, Charlie could say to himself, “I have nine hundred and ninety-nine million, nine hundred and ninety-nine satoshis of bitcoin.” This is how Charlie might mentally perceive the collection of money that exists in his digital wallet, like he perceives the $9,999 in his fiat wallet.

A Utxo is a Collection of Satoshis, just as a Fiat Dollar Bill is a Collection of Pennies

Recall now that with fiat money, Charlie did not think about how his original $10,000 was comprised of smaller individual $100-dollar bills. Similarly, Charlie also does not think about how his 9.99000999 BTC could be comprised of smaller collections of satoshis.

Furthermore, just as Charlie did not carry around fiat money as a collection of pennies, he also is not carrying around a raft of satoshis. Were he to try to carry a million pennies in his physical wallet, the weight of the wallet would be unmanageable. Similarly, if the Bitcoin protocol were to attempt to manage nine hundred and ninety-nine million, nine-hundred and ninety-nine satoshis, the “data weight” would be so heavy, the Bitcoin protocol would be enormous and unmanageable.

To optimize “data weight,” the Bitcoin protocol therefore bundles up the satoshis into something that is like the example of dollar bills earlier, but with one important difference. In fact, here is where the Bitcoin protocol exercises a superiority over fiat money by deviating from the limitations fiat money must obey when bundling smaller values into larger values.

In fiat money, one hundred pennies are bundled into a one-dollar bill, which can then be bundled into a larger bill, and so on. All the sizes of fiat money are preset and predetermined by the issuer of the fiat money when they print their bills and coins.

The Bitcoin protocol, however, does not need to pre-plan the sizes of “bills” (i.e. the collections of satoshis) in the owner’s wallet. Bitcoin is freer in this sense; it can shift and change the sizes of its “bills” at will because there is no need to accommodate for the printing of physical coins and paper.

Instead, the Bitcoin protocol allows for the developer of digital wallets to write code that can optimize how bitcoin satoshis are packaged into “bills,” and thus the community of developers can work together to keep the data weight of the blockchain manageable. The better the digital-wallet developer, the more efficient the size of the “bills” (a.k.a. the collections of satoshis).

The Bitcoin protocol does have one limitation, however: It must keep track of how these satoshis are being collected into larger “bills” in everyone’s digital wallets. After all, a key idea of Bitcoin is that everything happens under the public eye, where it can be verified.

Because the Bitcoin blockchain must keep track of the sizes of these collections of satoshis, the only time the collections can be assembled or disassembled into larger and smaller sizes is at the moment when the user is spending money on the public blockchain. It is at this time that the user is under the public eye, and therefore his actions can be verified.

To compare this limitation to fiat money, consider the effect created were Charlie to cut a $100-dollar bill into smaller pieces. The $100-dollar bill would no longer be respected as a valid form of currency.

As the word, “utxo,” is not a sonorous word, some users in the Komodo ecosystem simply refer to utxos as “bills.” The concept is effectively the same. However, as the rest of the blockchain industry primarily uses the word “utxo,” we frequently must use this word to maintain a common line of communication. The word utxo will be used throughout the rest of this documentation, to keep in line with industry practices.

The utxo collection can be any size, and the developer of the GUI software decides on this process. Most importantly, and to reiterate, a utxo can only be resized during the process of spending, as this is the moment when the user interacts with the public blockchain.

To further clarify this, let us return to Charlie’s example with fiat money. Recall that when Charlie went to purchase a $1-dollar item, he only had $100-dollar bills in his wallet. He had to give out one $100-dollar bill, and then receive a broken-down collection of dollar bills in return.

This is exactly how it works with utxos. Charlie has a collection of utxos in his digital wallet. When he goes to buy something, he will give out utxos until he surpasses how much he owes, and then the extra change from the last utxo used will be broken down and returned to him.

For example, let us suppose that Charlie’s 9.99000999 BTC is comprised of three utxos worth the following values:

Utxos in Charlie’s WalletValue
Utxo #1:0.50000000 BTC
Utxo #2:0.49000999 BTC
Utxo #3:9.00000000 BTC
Total9.99000999 BTC

Charlie now desires to purchase an item that costs 0.60000000 BTC. He will have to hand out enough utxos from his wallet until he covers the costs of this transaction, just as he would if he were using fiat money. The Bitcoin protocol calculates the change from the transaction and then returns his change to him.

Remember that there is a fee when spending money on a blockchain. Since we are using Bitcoin in this example, the fee would be paid to cryptocurrency miners. Let us imagine that the fee the miners charge Charlie is 999 satoshis.

We begin by looking at how Charlie would see the process of making the purchase, assuming he does not understand the concept of utxos. For now, Charlie only understands how much is in his wallet at the satoshi level as he conducts his transaction.

ValueDescription
9.99000999 BTCThe amount Charlie initially owns
(-) 0.60000000 BTCThe amount Charlie sends to the digital cashier for his purchase
(-) 0.00000999 BTCThe network fee paid to miners
———————————————————————————–
9.39000000 BTCThe amount left in his wallet

This deduction for his purchase all appears very simple to Charlie—a testament to the Bitcoin protocol’s effective design.

In the background, however, the digital wallet handles the utxos and the change process in a manner as determined by the programmer. In Charlie’s example, let us assume that it proceeds this way:

ValueDescription
0.60000999 BTCThe total amount that Charlie owes to the cashier and network
(-) 0.50000000 BTCThe wallet sends the full value of utxo #1 to the digital cashier
————————————————————————————————
0.10000999 BTCThis is the remaining total amount that Charlie still owes

The wallet now brings out utxo #2, which is worth 0.49000999 BTC:

This utxo is broken down or shattered into smaller pieces.

ValueDescription
0.49000999 BTCThe size of Charlie’s utxo #2, now in the process of change
(-) 0.10000000 BTCThis shatter of utxo #2 goes to the cashier (payment fulfilled)
(-) 0.00000999 BTCThis shatter of utxo #2 pays the network fee to the miners
——————–———————————————————————-
0.39000000 BTCThis last shatter now returns to Charlie’s wallet as a new utxo

Charlie now has one new utxo in his wallet, and it is worth 0.39000000 BTC:

Charlie’s New Wallet StateValue
Utxo #3:9.00000000 BTC
Utxo #4:0.39000000 BTC
—————————-—————-
Total9.39000000 BTC

If Charlie wants to buy something later, these utxos will have to be broken up once more, according to the costs and programming of the digital wallet. Again, whatever is left over from his last utxo comes back to his own wallet as a new utxo.

Now let us suppose that Charlie receives 0.4 BTC from someone else. In Charlie’s wallet, he will see a total of 9.79 BTC. However, in his wallet there are now actually three utxos:

Charlie’s New Wallet StateValue
Utxo #3:9.00000000 BTC
Utxo #4:0.39000000 BTC
Utxo #5:0.4000000 BTC
Total9.79000000 BTC

As a result, the number and sizes of utxos in Charlie’s wallet will vary over time. He may have many smaller utxos that make up his full balance, or sometimes he might just have one large utxo that comprises all of it. For Charlie, it is normally possible to ignore this since the wallet developer could handle everything automatically.

However, a developer in the Komodo ecosystem will likely encounter the concept of utxos in the course of software development, and therefore we encourage developers to practice their understanding.