Ch9: Something on Transaction UTXO

Ch9: Something on Transaction UTXO

?Different blockchain network structures its transaction differently. Bitcoin has adopted the UTXO(Unspent Transaction Output)-based transaction model, while Ethereum (another blockchain network) has adopted the Account-based transaction model. In this article I'll only talk about UTXO model.

Under the UTXO model, each bitcoin transaction is made up of one or more inputs and outputs. Each input is linked to the output of the previous transaction. And each output is linked to the input of the subsequent transaction.

No alt text provided for this image

The only bitcoin transaction that do not have an input is the first transaction in every blockchain block. The first transaction is called ‘coinbase transaction’ or ‘generation transaction’. Don't confuse it with the ‘Coinbase’ digital currency exchange company (denoted with capital C). I will talk more about coinbase in other articles.


Each transaction output will generate one or more new bitcoin ‘UTXO’. The transaction output ‘lock’ the newly generated UTXO to the new owner’s public key/public key hash/script hash. This means that the new owner now owns the bitcoins from the newly generated UTXO. The new owner who receives the newly generated UTXO will keep the new UTXO in his/her wallet. These UTXOs are 'unspent' (unused) and are available to be 'spent' for subsequent transaction.

No alt text provided for this image


If the owner decides to use the UTXO for a new transaction, the owner must 'unlock' the UTXO using his/her signature/public key/script and 'spent' the UTXO as an input to the new transaction. When UTXO is spent, it's no longer called UTXO. It's now called STXO (Spent Transaction Output). Therefore, a transaction consumes existing UTXOs at the input, and also generates new UTXOs at the output.

No alt text provided for this image


UTXOs are kept in a database called UTXO set. Full node stores this database in its computer’s RAM (Random Access Memory). Full node uses UTXO to validate all newly generated transactions by checking if the owner has enough balance in his/her wallet for the transaction, or if the owner uses UTXO that he/she has spent or uses UTXO that he/she does not owe.

To elaborate a bit more on ‘unspent’ & ‘spent’, just imagine that you've got some bitcoins in your wallet. If your wallet shows 8 bitcoins balance, this means that your 8 bitcoins are in one or more UTXOs (for example 1 BTC UTXO, 2BTC UTXO, 5 BTC UTXO) waiting to be used. In other words, you have three 'unspent' options to use bitcoins. If you have chosen to use the 1 BTC option, this means that the 1 BTC option is 'spent'. It will no longer be an option for you to use after you have ‘spent’ that option. Now you've just left with two options to use bitcoins, which is the option of 2 BTC and the option of 5BTC.

If you browse through some of the bitcoin transactions on the blockchain explorer, you may notice a red or green globe icon next to the output bitcoin value. The red globe icon means that output bitcoin is 'spent,' and the green globe icons means that output bitcoin is 'unspent'.

No alt text provided for this image


Now we're ready to look at an example when you want to send bitcoins to other people. Just follow the diagram step by step, which is quite self-explanatory.

No alt text provided for this image


I hope that the discussion so far will help you to understand UTXO better. It's okay if you're still confused about UTXO. It's one of Bitcoin's most difficult concepts to understand. It will be easy for you after a few readings. This concept will come in handy later for you to appreciate the unlocking/locking script.



Remember

·      Bitcoin transaction is made up of input and output.

·      Every bitcoin transaction has ‘unspent’ and/or ‘spent’ output.

·      Bitcoin transaction consumes existing UTXO (at the input) by unlocking it with current owner’s signature/public key/script and generates new UTXO (at the output) by locking it to the new owner’s public key/public key hash/script hash.


J.D. Salbego

Co-Founder Etheros Labs??| DeFi ??| Techstars & Founder Institute Startup Mentor ?? | 10 yrs BUIDLing the Web3 ?? | Advisor ?? | Public Speaker 45+ Conferences ?? | Contributor Live On-Air @FinTechGlobalTV @NYSE

4 年

????

回复

要查看或添加评论,请登录

Dr. AC Khor的更多文章

  • Battery Management System BMS

    Battery Management System BMS

    Recall that Battery pack (电池组/电池包) is made up of several modules (电池模块). Modules is made up of several cells (电池).

  • Battery for Electric Vehicle

    Battery for Electric Vehicle

    There are 3 types of chemical batteries: primary (non-rechargeable), secondary (rechargeable), fuel cell. The primary…

  • Battery Junction Box BJB

    Battery Junction Box BJB

    Battery Electric Vehicle's Battery Junction Box (BJB) has many other names: Recall that Battery Junction Box (BJB) is…

  • On-Board Charger OBC

    On-Board Charger OBC

    Recall that On-Board Charger (OBC) of a Battery Electric Vehicle (BEV) converts AC to DC. There are two types of OBC:…

  • Charging Electric Vehicle

    Charging Electric Vehicle

    Chargeable electric vehicle (EV) is known as PEV (Plug-in Electric Vehicle), which includes BEV (Battery Electric…

  • Battery Electric Vehicle (BEV)

    Battery Electric Vehicle (BEV)

    There are different types of electric vehicles, as shown in the diagram below. This article will focus on Battery…

  • Ch1: Who coined it?

    Ch1: Who coined it?

    The term ‘blockchain’ has become so widespread these days, yet many people may not know the origins of this word. A web…

  • Ch2: What is blockchain?

    Ch2: What is blockchain?

    A blockchain is a chain of blocks filled with data. The data may be in the form of currency transactions (eg: bitcoin…

  • Ch3: Something on Block

    Ch3: Something on Block

    We know there's data in a blockchain block. Aside from the data, it also contains a magic number, block size, block…

  • Ch4: Something on Node

    Ch4: Something on Node

    A node is a computer connected to a blockchain network. The blockchain network is therefore made up of many nodes.

社区洞察

其他会员也浏览了