This article is reproduced from TechFlow, author Echo, BiHelix (Satoshi Labs), guided by Hong Shuning, original link: https://www.techflowpost.com/article/detail_15632.html

"UTXO blockchains lay the foundation and undisputed foundation for today's blockchain industry. UTXO technology reflects Satoshi Nakamoto's core vision of ultimate financial freedom." The UTXO model ensures security, data privacy and scalability at the core of financial activities, and is a safer alternative to the Ethereum account model.

Blockchain Principles: The Basis of the UTXO Model

Blockchain is a digital, decentralized, distributed ledger. Blockchain uses a P2P (peer-to-peer) network, where participants are called nodes. The ledger stores data about transactions. The most important feature of blockchain is that blocks are linked together cryptographically.


Blockchain: Cryptographically linked together

Except for the first block (called the genesis block), each block in the blockchain contains a field called the "previous hash." It is the hash value of the previous block in the blockchain and is the basis of blockchain security.

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

1. Timestamp

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

3. Data: Transactions stored on blocks.

4. Random Numbers

If an attacker tries to change the data of a block, the hash of that block will change. As mentioned before, the next block will hold the hash of the current block, and if the hash changes, then the chain will be broken. Alternatively, the attacker will have to mine all blocks again from that point on. This is one possibility in a 51% attack.

What is a “block”?


Blocks in the blockchain store transactions. In the case of Bitcoin, blocks are added to the blockchain every 10 minutes, and depending on the complexity of the target hash, the time to mine a new block can vary.

  • When a miner successfully mines the block, it is added to the blockchain. When a block is added to the chain, the status of all transactions within the block changes from unconfirmed to confirmed.

  • In the case of Bitcoin, the number of transactions that can be stored in a block is not fixed, but the average block size is 1 MB.

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

Blockchain transaction structure

Peeling back a single transaction reveals several different structures with different semantics. Here are the different structures present in a transaction:

Transaction version number: It is the version number that specifies the transaction type to the network. Through the transaction number, the node can determine the set of rules used to verify this specific transaction.

  1. Output: The transaction output consists of a password lock and time.

  2. Input: A 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 pointed to by the input. Every time an output is unlocked by an input, it is marked as spent in the blockchain database.

  3. Locktime: Specifies whether a transaction can be included in the blockchain immediately or after a specified time.


UTXOs are all outputs that have not been unlocked by inputs.

Once outputs are unlocked, they are removed from the circulating supply. New outputs replace them. Therefore, the sum of unlocked outputs will always be equal to the sum of newly created output values.

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 in these denominations. UTXO stands for Unspent Transaction Output. In Bitcoin, a transaction exists until it is executed and until another transaction is completed from that UTXO. When a transaction is completed, the unspent output is stored back in the database as an input and can be used later in another transaction.

When a user initiates a transaction through a 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, records of ownership changes are filled in the database. Outputs are the portion of cryptocurrency that a user sends to someone but does not spend. They are recorded in the database as inputs to the cryptocurrency fraction.

When a user initiates a transaction through a 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, records of ownership changes are filled in the database. Outputs are the portion of cryptocurrency that a user sends to someone but does not spend. They are recorded in the database as inputs to the cryptocurrency fraction.


How are UTXOs created?

UTXOs are created by consuming existing UTXOs. Every Bitcoin transaction consists of inputs and outputs. Inputs consume existing UTXOs, while outputs create new UTXOs. When we decide to spend Bitcoin, we can only see the amount that has been deducted and the amount left in our wallet. For a user, this is similar to buying a $0.50 item with a $1 bill - you get the change and put it in your pocket.


Advantages of the UTXO model

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

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

  • Every transaction in the UTXO model can transition the system to a new state, but it is not feasible for every transaction to transition to a new state.

  • Network participants must stay in sync with the current state.

The total UTXOs present in the blockchain represent a set and are constantly maintained by every Bitcoin node.

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

  • The complete UTXO set can be added up to calculate the total supply of a 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. The condition that only unspent outputs can be used for further transactions is necessary to prevent double spending and fraud.


The difference between the UTXO model and the Ethereum account model

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


Technical Importance of UTXO

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

  • Support for decentralized exchanges and atomic swaps: The UTXO model can support atomic swaps, enabling peer-to-peer crypto transactions without the involvement of a third party. The atomic swap function of UTXO provides better convenience for direct cryptocurrency transactions between user wallets.

  • Scalability Benefits: The facility or parallel transaction processing reduces the computational load on the blockchain network.

  • Privacy and Security: Each UTXO transaction uses a new address, so transactions cannot be traced.

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

  • More Flexible: It offers more 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 that cryptocurrency. Because cryptocurrencies are created with anonymity in mind, UTXOs are associated with public addresses that are visible to the entire network.

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

UTXO use case: RGB off-chain transfer solution

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


working principle

In a contract of RGB, the genesis tokens belong to a Bitcoin UTXO (whether it already exists or is temporarily created), and in order to transfer the 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 RGB's payment information, which defines the input, which UTXO these tokens will be sent to, the asset's id, the amount, the transaction to spend, and the data it needs to attach.

Note: Bitcoin's first-layer asset issuance protocol RGB++ also uses UTXO as a one-time seal and was launched on the mainnet in early April. Click here to learn more about RGB++.

Summarize

The essence of UTXO is actually a kind of running account: the UTXO model is used to check whether the transaction funds exist, and then the source of the transaction is traced. After confirmation, it is broadcast to the entire network through the consensus mechanism and recorded on the chain. During the whole process, UTXO will record all the information involved, such as account funds, transaction addresses, transfer funds, and sources of funds, so that the original source of each transaction can be traced. It is precisely based on this feature that UTXO can solve the double-spending problem together with the consensus mechanism.

In general, UTXO can not only assist the consensus mechanism and solve the double-spending problem of the blockchain, but also give the blockchain the characteristic of traceability. The blockchain can also use this as a basis to ensure the authenticity and reliability of each transaction.