Home > web3.0 > body text

If you want to understand BRC-20 in depth, learn UTXO first

DDD
Release: 2024-03-06 13:34:09
forward
1271 people have browsed it

The recently popular BRC-20 Token is based on Bitcoin, but the Bitcoin blockchain cannot impose rules on it. The cost of making a BRC-20 Token lies in adding the file to the blockchain and the future movement of the UTXO associated with the Token.

Since UTXO is so important, today we will briefly introduce UTXO.

01. What is UTXO

In the current blockchain project, there are two main ways to save records, One is the account /Balance model, one is UTXO model. Bitcoin adopts the UTXO model, while Ethereum and others adopt the account/balance model.

If you want to understand BRC-20 in depth, learn UTXO first
##UTXO is the abbreviation of Unspent Transaction Output, which means

unspent output, can be simply understood as return There are no spent receipts. For example, Han Meimei received a Bitcoin, but she did not use it. This Bitcoin is a UTXO to her.

02. Account/balance model and UTXO model

Account/balance model is very common in life, such as our bank account and WeChat account, all based on account/ Balance model.

The balance in the account exists as a whole. How much money is in Li Lei's account? You can tell by looking at the balance. When a transaction occurs, it is the balance that changes. For example, on Valentine's Day, Li Lei transfers 520 yuan to Han Meimei via WeChat. Li Lei's WeChat account balance will decrease by 520 yuan, while Han Meimei's account balance will increase by 520 yuan.

The UTXO model is different from the account model.

How many Bitcoins Li Lei has can only be known by summing up all the UTXOs of his Bitcoin address. To put it simply, the UTXO model is like the wallet we use, and each banknote or coin in the wallet is a separate UTXO. Therefore, it is not clear at a glance how much money is in the wallet. All banknotes and coin denominations need to be compared. It can be found by adding.

Every payment or receipt is consumed or received in UTXO units. For example, when we use 10 yuan to buy 5 yuan breakfast, the 10 yuan will be paid to the seller as a UTXO, and the seller will give you change.

Let’s illustrate with an example.

On Valentine's Day, Li Lei bought flowers for Han Meimei, the price was 520 yuan. To pay in cash, he took out 6 hundred-yuan bills (equivalent to 6 100-yuan UTXOs) and gave them to the seller. The seller needed to give Li Lei 80 yuan in change (one each of 50-yuan, 20-yuan and 10-yuan bills). It is obvious in this process that Li Lei spent 600 yuan to buy flowers and received 80 yuan in change, and the seller sold the flowers and received 520 yuan.

From the perspective of UTXO, Li Lei spent 6 UTXO (6 pieces worth 100 yuan) and got 3 UTXO (3 pieces in change); the seller got 6 UTXO and spent 3 UTXO in change.

If this transaction is completed with Bitcoin, the process will be slightly different. Suppose Li Lei uses 6 UTXOs of 1 BTC to pay the seller 5.2 BTC. In the end, the seller gets

a value of 5.2 BTC. UTXO, The change given to Li Lei is a UTXO worth 0.8 BTC. In other words, 6 UTXOs were "destroyed" and turned into two new UTXO. (The reason for the difference between the two is that the types of banknote denominations are limited, while Bitcoin is not subject to this restriction). If the show of affection between Li Lei and Han Meimei takes place on the Bitcoin network, what is the transfer process?

Li Lei mined and received 12.5 Bitcoins as a reward from the system, so there was a UTXO of 12.5 BTC on Li Lei’s Bitcoin address.

Li Lei wants to transfer 5.2BTC to Han Meimei, and the 12.5BTC UTXO will be spent as a whole, of which 5.2BTC will be transferred to Han Meimei, and the remaining 7.3BTC will be given to himself in change (for the convenience of discussion, I will ignore it here Mining fees). In other words, 12.5 BTC previously existed in the form of a UTXO. During the transfer, this UTXO was "destroyed" and no longer existed. It became two new UTXOs: one belonged to Han Meimei, and the value of this UTXO 5.2BTC, the other one belongs to Li Lei, this UTXO is worth 7.3BTC, this is the change given to Li Lei.

If you want to understand BRC-20 in depth, learn UTXO first
Comparison of the two models when transferring money

03. Summary

The core design idea of ​​UTXO is: it records transaction events but not the final status. To calculate how many Bitcoins a user has, it is necessary to sum up all the UTXOs in his wallet, and the result is the number of coins he holds. The UTXO model uses UTXO as the unit when transferring transactions, which means that when making a payment, an integer multiple of UTXO is called, such as 1 UTXO, 3 UTXO, and there is no such thing as 0.5 UTXO.

Bitcoin’s General transactions: call one UTXO to pay other people, and Collection transactions: call multiple UTXOs to pay other people.

Can you name other types of transactions?

The above is the detailed content of If you want to understand BRC-20 in depth, learn UTXO first. For more information, please follow other related articles on the PHP Chinese website!

source:zhihu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template