Welcome to the Crypto Explained series of blog posts where we explain technical terms in an accessible manner. In this post I’ll explain the UTxO model, the accounting model that underpins Bitcoin and Cardano.
Transaction outputs are either spent or unspent
Imagine you have a 5 dollar bill in your pocket. But instead of dollar let’s say its in Cardano’s native currency Ada. And instead of calling it a bill, let’s be fun and call it a “UTXO” (Unspent Transaction Ouput). Ok so you have a single UTXO worth 5 Ada in your pocket.
Now you want to purchase a 3 Ada coffee. Great. You hand over your single UTXO. You can’t divide that UTXO, and hand over the exact amount; you have to hand over the entire UTXO.
The cashier takes your UTxO and tears it up, so that it can never to be used again. They then give you a new UTXO worth 2 Ada as well as giving themselves a new UTxO worth 3 Ada. So the end result is that the total amount of money on the system is still the same, but there now exists a new set of UTxOs representing the total amount of money in the system. This is what UTxOs are, the total money in the system aka the total unspent money in the system aka total UTxOs in the system.
A Bitcoin or Cardano node keeps a record of the current set of UTxOs. One user on Discord provided this excellent explanation of this:
“A node keeps the current set of UTxOs – Whenever a transaction consumes an UTxO, this UTxO is no longer “unspent”, so it is removed from the set of UTxOs – The outputs of the transactions are added to the UTxO set – This UTxO set can be computed directly from the Blockchain: Start with an empty UTxO set and iterate over all transactions, updating your UTxO set along the way – So in essence: The UTxO set is the important, essential part of the blockchain which is required for adding new transactions to the chain (you dont need spent transaction outputs) – But doing this iteration over all transactions of a blockchain is very time consuming, hence computing it once and storing it as a set. This helps to process new transactions faster.” (Matthias, Discord)
As soon as an output is used as input in a transaction, it becomes spent and can never be used again. The output is specified by an address (a public key or public key hash) and a value (consisting of an ada amount and optional, additional native token amounts). An output’s address determines which transactions are allowed to ‘unlock’ the output and use it as an input. A transaction must be signed by the owner of the private key corresponding to the address. Think of an address as a ‘lock’ that can only be ‘unlocked’ by the right ‘key’ ‒ the correct signature.
Transaction are built on top of one another
You can think of the above process as inputs into a transaction and outputs of a transaction, as depicted in this Directed Acyclic Graph (DAG) from blog.bitnovo.com.
A DAG is a chart which has many items interacting with many other items, however the movement does not circle back onto itself. So here the process moves from left to right, represented by new transactions.
Transactions are built on top of each other and each new transaction contains information that links it back to the inputs it consumed, and those inputs contain information linking it back to their inputs and so on.
This means every time a transaction is validated and receives an imaginary thumbs up, all the transactions that came before it also get a thumbs up and hence shouldn’t need checking from the bottom up every single time.
So a DAG is a great way to represent blockchain transactions in which you have multiple wallets interacting with multiple other wallets. But with Bitcoin, it’s been built to only let you keep track of the monetary value from one transaction to the next, nothing more than that. This is why Bitcoin isn’t considered a smart contract platform. But what if in addition to recording monetary value in the system, you also recorded data, and that data could represent anything at all? This is the underpinning of Cardano’s Extended UTXO model and smart contract system, which we will cover in another post.