What do we mean by UTXOs?

What do we mean by UTXOs?

Anyone learning Blockchain Technology will be puzzled by the concept of UTXOs and how they enable blockchain protocols (specifically Bitcoin protocol) to make transactions.

I will be talking about Bitcoin, which uses the UTXO model to keep track of transactions and detect double-spending. Ethereum uses the Account/Balance Model for keeping track of the balance of a particular account. UTXO stands for Unspent Transaction Output. UTXO is of two types:

  • Input UTXO
  • Output UTXO

In bitcoin, the funds in a transaction are treated as a single unit, and to spend the funds received from a transaction, you have to spend the entire fund referenced in that input transaction. If you only want to spend only a fraction of the bitcoin in that referenced by that input transaction, then you need to create two transactions, one to the potential receiver’s account and another to your account.

Input UTXOs are basically the transactions whose funds have not been spent, i.e. not yet referenced as an input to any other transaction.

Output UTXO are the transactions which are generated after a transaction becomes successful.

Understanding Transactions in UTXO model

Transactions in my account

  1. Consider these bitcoin transactions, which result in transferring a sum of 0.61 BTC to my account.
  2. Now I want to buy a truck that costs 0.55 BTC.
  3. Now, to spend 0.55 BTC, I have to reference one or more transactions called input transactions whose cumulative sum is equal to or more than 0.55 BTC.
  4. If I have an option to choose from those transactions shown above (let’s suppose all other transactions referencing my account are either output transactions — where I am sender), then I have only one option for a set of input transactions, i.e. first and second transactions.
  5. But hey, these transactions result in 0.6 BTC, then where is the remaining 0.05 BTC going after I pay for 0.55 BTC? These remaining amounts can be used in these three ways: -

    • Send the remaining amount back to your account.
    • Use the remaining amount as the transaction fee. Every transaction on the blockchain has associated transaction fees.
    • Send the remaining amount to someone else. Input and Output UTXOs
  6. After the transaction is confirmed, the transactions in my account will look like this: Finally transactions in my account

  7. The first two transactions that have now been spent can’t be referenced as input UTXOs to any other transactions.

  8. The transaction in purple is the outgoing transaction (BTC is sent and not received), so it also can’t be used as input UTXO in any transaction.

  9. The 3rd and the 5th transaction shown in green are the transactions which are unspent and can be used as input UTXO to other transactions.

That’s about it for now.

Adios 👋