Unspent Transaction Output — or — “UTXO” as they are more commonly referred to, is an integral part of how Bitcoin and Bitcoin-based cryptocurrency transactions occur. In this article, we will cover the basics of how they function and give some examples of how they play their part in a blockchain. We will use Vidulum as an example!
When you look at your balance in a wallet, your total balance is shown. For the sake of example — let's say you have a balance of 1000 VDL in your Vidulum wallet that you have saved up. Although your total balance is 1000, the VDL is actually split up into different sized UTXO’s — that when added together equal 1000.
The size of each UTXO will vary. For example, you could have five 200 VDL UTXO’s (5 x 200 = 1000), or; one 750, one 200, one 40, and one 10 VDL sized UTXO’s (750 + 200 + 40 + 10 = 1000) and so on. All of the UTXO’s spanning the entire blockchain (everyone's “coins”) is known as the UTXO set. The subset of UTXO’s that comprise your wallet is referred to as a reference UTXO set. Keep in mind that UTXO’s are not necessarily whole numbers (Vidulum, like Bitcoin, uses the standard 8 decimal points, aka ‘satoshis’) in fact most of the time they are not, but for the scope of this article we will use whole numbers to more easily demonstrate how they work.
One important thing to understand is that a UTXO cannot be “split” — each UTXO must be spent in its entirety.
Let’s walk through how that looks.
Continuing with the example wallet with a 1000 VDL balance, let’s say the user wishes to send 825 VDL to a friend. Also, let's assume that the local reference UTXO set is the four UTXO’s mentioned above; 750, 200, 40, and 10. When the user sends the 825 VDL, behind the scenes, the wallet will look through the available UTXO’s and combine the ones needed to satisfy sending 825 VDL. Because they cannot be split (much like how you cannot cut a dollar bill in half) the wallet will typically use the smallest number of, and smallest size UTXO’s needed to equal at least 825 VDL. Depending on the wallet, the process of deciding which UTXO to use may differ — however, the above method is common. As a regular user, in most cases, you have no control over this.
So, in this example, we have both the 750 VDL and 200 VDL UTXO’s. In this case, these two are the only ones that can be combined to get to 825 — no matter how you add the four up, the 40 and 10 UTXO’s don’t fit, so they will be ignored. Together, these two UTXO’s equal 950 VDL. So what happens to the extra VDL?
This is where the concept of change, and “change addresses” are introduced. When the user sends the 825 VDL, both the 750 and 200 UTXO’s are used. The remainder, in this case, 125 VDL (950-825 = 125) will be sent back to the sender as change. Depending on the wallet, the change will be sent back to the same address it was sent from, or another new address will be created to accept the change. This is where the term “change address” originates.
In doing so, two new UTXO’s are created — the 825 VDL going to the recipient, and the change of 125 VDL.
What if the user wanted to send another amount, say 45 VDL to a friend? Well, the same process occurs, the wallet would typically choose the 10 and 40 VDL UTXO’s (the smallest amount of and smallest sized UTXOs to satisfy the amount of 45; as 10 + 40 = 50) and both UTXO’s would be spent. The 45 VDL would go to the recipient, and the remainder of 5 VDL would be returned as change (50-45 = 5) to the sender's wallet.
Below you can see this in action. This is a snip from the Vidulum block explorer. You can see the 31112.76376313 VDL UTXO, being used to send exactly 15,000 VDL to another address, and the remainder of 16112.76276313 VDL being sent back to the same sending address as change.
One thing to note when sending from exchange addresses, most times your transaction will get sent as part of a batch of transactions (multisend) so when looking on a block explorer it will not always be so obvious.
A great analogy for the concept of UTXO’s and change is fiat currency (dollar bills and coins). Firstly, they cannot be physically split, and second, when you spend a bill that is more than the total needed for the recipient, one gets change back. For example, if you have a $5.00 bill, and use it to pay for a donut that costs $1.25, you have to use the whole $5 dollar bill and would receive $3.75 in change, and you would put that change back in your wallet.
I hope this has shed some light on the topic, and next time it comes up in conversation or research, instead of “UTX-What?” you’ll think — “UTX-OH!”
Jeremy ‘NERDiT’ Dixon