A must-read guide to Bitcoin (Part II): Past and Present of UTXO Model

BeginnerJan 22, 2024
This article introduces the UTXO model in detail. UTXO can not only assist the consensus mechanism and solve the double-spending problem in the blockchain, but also gives blockchain the characteristics of traceability.
A must-read guide to Bitcoin (Part II): Past and Present of UTXO Model

Introduction

“UTXO blockchain laid the foundation and undisputed foundation of today’s blockchain industry. UTXO technology reflects Satoshi Nakamoto’s core vision for ultimate financial freedom.” The UTXO model guarantees security, data privacy and security at the heart of financial activities. Scalable and a safer alternative to the Ethereum account model.

Blockchain Principles: The Basis of the UTXO Model

Blockchain is a digital, decentralized, distributed ledger. Blockchain utilizes a P2P (Peer to Peer) network, where participants present on the network are called nodes. The ledger stores data about transactions. It is a chain of blocks, where its most significant feature is that blocks are cryptographically linked together.

Blockchain: Cryptographically linked together

• Each block in the blockchain except the first block (known as the genesis block) contains a field called a previous hash. It is the hash of the previous block in the chain. This makes blockchain very secure.

• Factors that determine block hash value. If any of these four factors changes, even by 1 bit, due to the avalanche effect, the hash will completely change. Transactions are stored within blocks and are one of four factors that change the block hash. This means that if a miner chooses a different transaction and keeps the other 4 factors the same, the hash value will be different.

  1. Timestamp

  2. Block number:The sequence number of the current block in the chain.

  3. Data:Transactions stored on blocks.

  4. Random number

• If an attacker attempts to change the data of a block, the hash of the block will change, as stated earlier, the next block will be holding the hash of the current block, if the hash changes the chain will get destroyed. Or, the attacker has to mine all the blocks again from that point. This is a possibility in a 51% attack.

What is a “block”?

A block in blockchain stores transactions. In the case of bitcoin, blocks are added to the blockchain every 10 minutes, this might vary as a time to mine a new block depending on the complexity of the target hash, and it might take more time to mine one block, compared to the other.

• When the block successfully gets mined by the miner, it gets added to the blockchain. When the block gets added to the chain, the status of all the transactions inside the block changes from unconfirmed to confirmed.

• In the case of bitcoin, the number of transactions that can be stored inside a block isn’t fixed, but the maximum size of the block is set to roughly 1 MB, the block size can slightly vary from 1 MB.

• Empty blocks are valid, which means an empty block can be mined and added to the chain.

Blockchain Transaction Structure

Peeling down a single transaction reveals several different structures with different semantics within the transaction. The following are the different structures present in transactions:

  1. Transaction version number: It is a version number specifying the type of transaction to the network. Through the transaction number, a node can determine the set of rules to be used to verify this particular transaction.
  2. Output: Transaction output consists of a cryptographic lock and time.
  3. Input: Transaction input consists of a pointer and an unlocking key. The pointer points to the previous transaction output. The unlocking key is used to unlock the previous output the input points to. Every time output is unlocked by an input, it is marked in the blockchain database as spent.
  4. Lock Time: It specifies whether a transaction can be included in the blockchain right away or after some specified time.

UTXO is all those outputs that are yet to be unlocked by an input.

Once an output is unlocked, they are removed from the circulating supply. The new outputs take their place. Thus, the sum of the unlocked outputs will always be equal to the sum of values of the newly created outputs.

What is the UTXO model?

UTXO is not a cryptocurrency denomination, such as satoshi for Bitcoin (BTC) or gwei for Ethereum (ETH); however, UTXO can be measured using these denominations. UTXO stands for Unspent Transaction Output. In Bitcoin, a transaction remains in existence until it is executed, until another transaction completes using that UTXO. When a transaction is completed, the unused outputs are stored back into the database as inputs and can be used for another transaction later.

When a user initiates a transaction through their wallet, the UTXO containing the transaction information is located, unlocked, and the new owner’s information is associated with the UTXO transferred to them. And that user can use them in transactions through the same process. As transactions continue, the database will be populated with records of ownership changes. The output is a portion of the cryptocurrency that the user sent to someone but did not spend. They are logged into the database as input to the cryptocurrency score.

How is a UTXO created?

UTXOs are created through the consumption of existing UTXOs. Every Bitcoin transaction is composed of inputs and outputs. Inputs consume an existing UTXO, while outputs create a new UTXO. When deciding to spend Bitcoins, we can only see the deducted amount and the remaining amount in the wallet. For the user, this is similar to buying a $0.50 item with a $1 bill—it’s like receiving change and putting it in your pocket.

Advantages of UTXO model

The UTXO model does not incorporate wallets at the protocol level. It is based on individual transactions that are grouped in blocks. The UTXO model is a design common to many cryptocurrencies, most notably Bitcoin.

• Cryptocurrencies using the UTXO model do not use accounts or balances. Instead, UTXOs are transferred between users, just like physical cash.

• Each transaction in the UTXO model can transition the system to a new state, but transitioning to a new state with each transaction is infeasible.

• The network participants must stay in sync with the current state.

The total UTXOs present in a blockchain represents a set and is being constantly maintained by every bitcoin node.

• Each transaction consumes elements from this set and creates new ones that get added to the set. UTXO set is updated every time a new block is accepted in the blockchain, and every Bitcoin node in the network will have the exact copy of the UTXO set in their local storage.

• The complete UTXO set can be added up to calculate the total supply of the cryptocurrency at a given point in time, and in the case of valid blockchain transactions, only unspent outputs can be used to fund further transactions. To prevent double-spending and fraud, a condition that only unspent outputs can be used in further transactions is necessary.

The difference between the UTXO model and the Ethereum accounting model

Unspent transaction outputs are part of the distributed database technology behind Bitcoin and other cryptocurrencies. Bitcoin uses UTXO, but it is not a UTXO. Additionally, Ethereum uses an accounting-based approach and account balances, so there are no UTXOs in the Ethereum Virtual Machine.

Technical importance of UTXO

• Language-agnostic smart contracts: UTXO-based smart contracts are language independent, allowing UTXO to develop unique consensus mechanisms.

• Supports decentralized exchanges and atomic swaps: The UTXO model can support atomic swaps, enabling peer-to-peer encrypted transactions without third-party involvement. The atomic swap feature of UTXOs offers a better facility for direct cryptocurrency trades between user wallets.

• Scalability benefit: Facility or parallel transaction processing reduces computation load on the blockchain networks.

• Privacy and security: With new addresses used for every UTXO transaction, it is impossible to track the transactions

• Prevent double spending: A UTXO can only be used once, which is the basis for the operation of blockchain technology and ensures that the currency will not be used multiple times.

• More flexible: It offers greater flexibility than fiat currencies.

• Simple parallelization: It allows for simpler parallelization of transactions in smart contracts.

The UTXO model is used in many cryptocurrencies because it allows users to track ownership of all parts of the cryptocurrency. Because cryptocurrencies are created with anonymity in mind, UTXOs are associated with public addresses visible to the entire network.

Users cannot be identified by their ownership unless they publish their address, but the model allows for transparency through addresses.

UTXO use case application—RGB off-chain transfer solution

The core concept of the RGB protocol is to only call the Bitcoin blockchain when necessary, using proof-of-work and the decentralized network to achieve double-spending protection and censorship resistance. The validation of all token transfers is moved from the global consensus layer to off-chain, and is only verified by the client receiving the payment.

Working Principle:

In a certain contract of RGB, the genesis tokens belong to a Bitcoin UTXO (whether it already exists or is temporarily created), and in order to transfer tokens, you need to spend this UTXO. When spending this UTXO, the Bitcoin transaction must add an additional output, which contains a commitment to a message. The content of this message is the RGB payment information, which defines the input and which UTXO these tokens will be sent to, the asset’s ID, quantity, the spending transaction, and the data it needs to attach.

Conclusion

The essence of UTXO is actually a form of flow-based accounting: it verifies the existence of transaction funds through the UTXO model, and then traces the source of the transaction. After it is confirmed to be correct, it will be broadcast to the entire network through the consensus mechanism and recorded on the chain. Throughout this process, UTXO records all the information related to the involved account funds, transaction addresses, transferred funds, and fund sources, allowing for tracing the original source of each transaction. It is precisely based on this characteristic that UTXO can work together with the consensus mechanism to solve the double-spending problem. The security and integrity of transaction information in the RGB protocol are ensured through UTXO.

In summary, UTXO can not only assist the consensus mechanism and solve the double-spending problem of the blockchain, but also give blockchain characteristics of traceability. Based on this, blockchain can guarantee the authenticity and reliability of each transaction.

Disclaimer:

  1. This article is reprinted from aicoin]. All copyrights belong to the original author [Echo,BiHelix;Satoshi Labs]. If there are objections to this reprint, please contact the Gate Learn team, and they will handle it promptly.
  2. Liability Disclaimer: The views and opinions expressed in this article are solely those of the author and do not constitute any investment advice.
  3. Translations of the article into other languages are done by the Gate Learn team. Unless mentioned, copying, distributing, or plagiarizing the translated articles is prohibited.
Start Now
Sign up and get a
$100
Voucher!
Create Account