Bitcoin Ordinals Inscription and BRC-20: Pandora’s Box

Intermediate28.43
This articleTo understand the inscription from the perspective of NFT compared to ETH,combined with current eventsExploring the centralization problem of BRC-20.
Bitcoin Ordinals Inscription and BRC-20: Pandora’s Box

What is the Ordinals inscription?

Ordinals was launched by developer Casey Rodarmor on January 20, 2023, on the Bitcoin mainnet as an ordering protocol for “Satoshis”. “Satoshis” are the smallest unit of Bitcoin, and each Bitcoin is composed of one Composed of 100 million Satoshis (1 btc = 10^8 sat), the Ordinals protocol gives each Satoshi a unique identity.

Ordinals Inscriptions are non-fungible tokens (NFT) built on the Ordinals protocol and contain data such as images, text, and videos.

Compared with Ethereum NFT, we can simply think that the Ordinals protocol implements tokenID and the inscription implements metadata.

How to implement tokenID

TokenID provides a unique identifier for each NFT, allowing users to distinguish tokens from one another. TokenID is what makes NFTs truly unique.

Ethereum has good programmability, making it easy to implement TokenID. However, in Bitcoin, similar implementations usually require the use of second-layer networks. Platforms such as Counterparty and Stacks have already implemented Bitcoin-based NFTs, but the Ordinals inscription has fundamental differences from other Bitcoin NFT architectures.

The Ordinals protocol utilizes Bitcoin’s UTXO transaction model. UTXO is similar to a cash system, as opposed to the traditional account balance-based model.

In the Bitcoin blockchain, all balances are stored in a list called Unspent Transaction Outputs (UTXOs). Each UTXO contains a certain amount of Bitcoin, along with information about its owner and whether it is spendable. You can think of it as a cash check with the owner’s name on it, which can be transferred to someone else by the owner’s signature. For a specific address, the sum of all its UTXO amounts represents the balance of that address’s wallet. By iterating through all UTXOs, we can obtain the current balance for each address. Adding up all UTXO amounts gives us the total circulation of Bitcoin.

To better understand the payment model in the Bitcoin network, let’s go through an example of A sending n Bitcoin to B. The diagram below illustrates the process of A sending 3 Bitcoin to B.

  1. For user A, first need to determine the set of all UTXOs he owns, that is, all the Bitcoins that user A can control;

  2. A selects one or more UTXOs from this set as the input of the transaction. The sum of the amounts of these inputs is m (2+0.8+0.5=3.3 BTC), which is greater than the amount to be paid n (3 BTC);

  3. User A sets two outputs for the transaction, one output is paid to B’s address, the amount is n (3 BTC), and the other output is paid to A’s own change address, the amount is m-n-fee (3.3-3- 0.001=0.299 BTC). A user’s wallet usually consists of multiple addresses. Generally, each address is only used once, and change is returned to a new address by default;

  4. After the miner packages the transaction and uploads it to the chain for confirmation, B can receive the transaction information. Because the block size has an upper limit (approximately 1 MB), miners will prioritize transactions with high transaction rates (fee_rate=fee/size) to obtain the highest fee in return.

According to the Ordinals protocol, the number of “Satoshi” is based on the order in which they are mined, and since each “Satoshi” BTC is generated through mining rewards, its serial number can be determined through traceability.

Assume that user A obtains the 100th-110th Satoshi through mining (10 Satoshis are stored as a whole in the same UTXO with the ID adc123). When user A wants to pay 5 satoshis to user B, he chooses to use the ID abc123 as the input of the transaction, of which 5 satoshis are given to user B, and 5 satoshis are returned to user A as change. These two copies of 5 “Satoshi” are a whole and are stored in two UTXOs with IDs abc456 and abc789 respectively. The above UTXO id and the number of “Satoshi” are only shown as examples. In actual situations, the minimum number of “Satoshi” sent is limited to 546 and the UTXO id is not expressed in this form.

In the above transaction, the circulation path of User A’s 10 Satoshis is:

  1. Mining produces 10 “Satoshi”, numbered [100, 110). Indicates that the 100th to 109th “Satoshi” is stored in the UTXO with the ID abc123, and its owner is user A.

  2. When A transfers money, 10 “satoshis” are divided into two parts, each with 5 “satoshis”. Used here”First come, first served”The principle is that the number ordering of “Satoshi” is determined according to their index in the transaction output. Assuming that the order of output is user A first, then user B, then the serial numbers of user A’s remaining 5 “satoshis” are [100, 105), which are stored in the UTXO with the id abc456, and user B’s 5 “satoshis” The sequence number is [105, 110) and is stored in the UTXO with id abc789.

How to implement metadata

Metadata for Ordinals inscriptions is not stored in a specific location. Instead, this metadata is embedded in the transaction’s witness data (witness data, witness field), which is why it is called an “inscription” because this data is “engraved” like an inscription on specific parts of the Bitcoin transaction. , and these data are attached to specific “Satoshi”. This inscription process is implemented through Segregated Witness (SegWit) and Taproot, which includes two stages: commit and reveal, and can inscribe any form of content (such as text, image or video) on the designated “satoshi”.

SegWit is a 2017 update that resulted in a soft fork of the Bitcoin blockchain. The update effectively separates Bitcoin transactions into two parts by adding a “witness data” section that can support arbitrary data.

Segregated Witness separates transaction and witness (signature) data into separate parts and enables arbitrary data to be stored in the witness part.

Technically, the implementation of Segregated Witness means that transactions no longer need to include witness data (and will not take up the 1MB of space that Bitcoin originally allocated for blocks). Instead, at the end of a block, an additional separate space is created for witness data. It supports arbitrary data transfers and has a discounted “block weight” that cleverly keeps large amounts of data within Bitcoin’s block size limits to avoid the need for a hard fork.

Implemented in November 2021, Taproot is a multi-faceted upgrade designed to improve Bitcoin’s privacy, scalability, and security. Taproot creates a system that makes it easier to store arbitrary witness data and relaxes the limits on how much arbitrary data can be placed in a Bitcoin transaction. The initial goal of this upgrade is to further enhance Bitcoin-based smart contracts, such as time-locked contracts, which are typically expressed in witness data.

Ordinals store metadata in a spend script in the Taproot script path.

First, due to the way Taproot scripts are stored, we can store inscription content in Taproot script path expenditure scripts, which have almost no restrictions on content, while also receiving discounts on witness data, making storing inscription content relatively economical. Since consumption of Taproot scripts can only be done from already existing Taproot output, Inscriptions are minted using a two-stage commit/reveal process. First, in the commit transaction, a Taproot output is created that promises a script containing the inscription content. Then, in the reveal transaction, a transaction is initiated by taking the UTXO corresponding to that inscription as input. At this time, the corresponding inscription content was made public to the entire Internet.

This approach greatly reduces the consumption of resources. If you do not use the Taproot script, the witness information is stored in the output of the transaction. In this way, as long as this output is not consumed, the witness information will always be stored in the UTXO set. In contrast, if P2TR is used, the witness information will not appear in the transaction generated during the commit phase, so it will not be written to the UTXO set. Only when this UTXO is consumed will the witness information appear in the transaction input during the reveal phase. P2TR enables metadata to be written to the Bitcoin blockchain, but never appears in the UTXO set. Since maintaining/modifying the UTXO set requires more resources, this approach can save a lot of resources.

What is BRC-20

Although the name of BRC-20 is very similar to Ethereum’s ERC-20, the technical differences between the two are actually significant. The holding status of ERC-20 tokens is saved on the chain, and network consensus can be obtained on the chain, while BRC-20 Just a special Ordinals protocol inscription, created by Twitter user @domodata on March 8, 2023, that utilizes ordinal inscriptions of JSON data to deploy token contracts, mint and transfer tokens. The deployed json is as follows:

{  

"p": "brc-20",//Protocol: Helps offline accounting systems identify and handle brc-20 events

"op": "deploy",//op operation: event type (Deploy, Mint, Transfer)

"tick": "ordi", //Ticker: identifier of the brc-20 token, 4 letters in length (can be emoji)

"max": "21000000",//Max supply: The maximum supply of brc-20 tokens

"lim": "1000"//Mint limit: The limit on the minting amount of brc-20 tokens each time

}

The corresponding ops are mint and transfer, and the two formats are almost the same. When op is Transfer, the transfer recipient of the inscription is the recipient of the “Satoshi” corresponding to the inscription. Therefore, the transfer of BRC-20 must be accompanied by the transfer of Bitcoin ownership and not just consumed as a handling fee.

BRC-20 implements a “first come, first served” mechanism. Repeated deployments and excessive mint are invalid. The centralized organization will deduce the current balance that the user should have based on each OP registered on the chain, and Make a judgment on the validity of the transaction.

In this process, the inscriptions are ‘attached’ to the transactional “Satoshi”. Bitcoin miners will not process these inscriptions. From the perspective of the chain, they are still no different from other “Satoshis”. They are all regarded as ordinary “Satoshis”. “Cong” is transferred.

Centralization problem of BRC-20

For the BRC-20 protocol, it treats the inscription as a ledger that records the deployment, minting, and transfer of BRC-20 tokens. Since smart contracts cannot be run on Bitcoin, BRC-20 tokens cannot query relevant information about the current token by running smart contracts. Therefore, BRC-20 uses off-chain queries, that is, using a centralized server to retrieve Bitcoin blocks, record the deployment, minting and transfer operations of all BRC-20 tokens to query the final balance of each user’s BRC-20 tokens.

Simply put, the BRC-20 ledger is decentralized and recorded on the Bitcoin chain, but the settlement process is centralized. There are currently two websites, brc-20.io and unisat.io, that support queries related to BRC-20 tokens.

The centralization of the settlement process may cause different platforms to have different results when querying a certain account balance. Although all operations are recorded on-chain, it is the responsibility of a client to verify these operations. If these centralized service providers do not disclose their verification rules, then there is actually no guarantee for the entire BRC-20 ecosystem.

In fact, on the evening of April 23, UniSat launched the BRC-20 trading platform, but due to vulnerabilities in the code library, it suffered a large number of double-spending attacks. The address bc1pwturekq4w455l64ttze8j7mnhgsuaupsn99ggd0ds23js924e6ms9fxyht initially minted the transferred Ordinals NFT and tried to transfer 5,000 ORDI and 35,000 ORDI to his own address out of thin air, and tried to sell the ordi minted out of thin air to other users. Unisat subsequently suspended access to the website and conducted an investigation, ultimately discovering that 70 transactions were affected.

Had Unisat not retrieved the error that night, the damage from the double-spend attack was estimated to be in excess of $1 million. How to ensure that the centralized server retrieval and verification is error-free is the most important issue that needs to be solved during the development of BRC-20.

Conclusion

The essence of the Ordinal inscription is: on the Bitcoin network with the help of aTaproot The script builds a simple accounting layer to count and record assets and data.

Since it only involves accounting, this means that there will be no script execution and verification processes similar to smart contracts, and it must be highly dependent on off-chain centralized management and reporting results.

Therefore, except for BRC-20, all Ordinals inscriptions must be based on offline services outside the Bitcoin network for state maintenance as long as they involve state transfer (such as transactions). If the underlying state service is unavailable or defective, it may lead to asset losses, because the Bitcoin network cannot prevent invalid inscriptions from being uploaded to the chain. The centralized platform must decide whose inscription is valid, and it will be valid on the platform.

This centralized trading and pricing method gives the centralized platform a significant opportunity for malicious behavior. Additionally, the combination of the logical paradox of the “first come, first served” inscription and the mechanism of miners prioritizing packaging based on mining fees allows miners and front-running robots to mint a large number of popular inscriptions before others, resulting in an unfair minting process.

However, predicting and assessing the development of new things is challenging. The introduction of the Ordinal inscription has undoubtedly sparked a debate within the Bitcoin community regarding the fundamental role and essence of Bitcoin. This discussion could potentially lead to a fork in Bitcoin, focusing on security and programmability. It seems that Pandora’s box is being opened.

Disclaimer:

  1. This article is reprinted from [小猪Go]. All copyrights belong to the original author [web3朱大胆]. 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.

Bitcoin Ordinals Inscription and BRC-20: Pandora’s Box

Intermediate28.43
This articleTo understand the inscription from the perspective of NFT compared to ETH,combined with current eventsExploring the centralization problem of BRC-20.
Bitcoin Ordinals Inscription and BRC-20: Pandora’s Box

What is the Ordinals inscription?

Ordinals was launched by developer Casey Rodarmor on January 20, 2023, on the Bitcoin mainnet as an ordering protocol for “Satoshis”. “Satoshis” are the smallest unit of Bitcoin, and each Bitcoin is composed of one Composed of 100 million Satoshis (1 btc = 10^8 sat), the Ordinals protocol gives each Satoshi a unique identity.

Ordinals Inscriptions are non-fungible tokens (NFT) built on the Ordinals protocol and contain data such as images, text, and videos.

Compared with Ethereum NFT, we can simply think that the Ordinals protocol implements tokenID and the inscription implements metadata.

How to implement tokenID

TokenID provides a unique identifier for each NFT, allowing users to distinguish tokens from one another. TokenID is what makes NFTs truly unique.

Ethereum has good programmability, making it easy to implement TokenID. However, in Bitcoin, similar implementations usually require the use of second-layer networks. Platforms such as Counterparty and Stacks have already implemented Bitcoin-based NFTs, but the Ordinals inscription has fundamental differences from other Bitcoin NFT architectures.

The Ordinals protocol utilizes Bitcoin’s UTXO transaction model. UTXO is similar to a cash system, as opposed to the traditional account balance-based model.

In the Bitcoin blockchain, all balances are stored in a list called Unspent Transaction Outputs (UTXOs). Each UTXO contains a certain amount of Bitcoin, along with information about its owner and whether it is spendable. You can think of it as a cash check with the owner’s name on it, which can be transferred to someone else by the owner’s signature. For a specific address, the sum of all its UTXO amounts represents the balance of that address’s wallet. By iterating through all UTXOs, we can obtain the current balance for each address. Adding up all UTXO amounts gives us the total circulation of Bitcoin.

To better understand the payment model in the Bitcoin network, let’s go through an example of A sending n Bitcoin to B. The diagram below illustrates the process of A sending 3 Bitcoin to B.

  1. For user A, first need to determine the set of all UTXOs he owns, that is, all the Bitcoins that user A can control;

  2. A selects one or more UTXOs from this set as the input of the transaction. The sum of the amounts of these inputs is m (2+0.8+0.5=3.3 BTC), which is greater than the amount to be paid n (3 BTC);

  3. User A sets two outputs for the transaction, one output is paid to B’s address, the amount is n (3 BTC), and the other output is paid to A’s own change address, the amount is m-n-fee (3.3-3- 0.001=0.299 BTC). A user’s wallet usually consists of multiple addresses. Generally, each address is only used once, and change is returned to a new address by default;

  4. After the miner packages the transaction and uploads it to the chain for confirmation, B can receive the transaction information. Because the block size has an upper limit (approximately 1 MB), miners will prioritize transactions with high transaction rates (fee_rate=fee/size) to obtain the highest fee in return.

According to the Ordinals protocol, the number of “Satoshi” is based on the order in which they are mined, and since each “Satoshi” BTC is generated through mining rewards, its serial number can be determined through traceability.

Assume that user A obtains the 100th-110th Satoshi through mining (10 Satoshis are stored as a whole in the same UTXO with the ID adc123). When user A wants to pay 5 satoshis to user B, he chooses to use the ID abc123 as the input of the transaction, of which 5 satoshis are given to user B, and 5 satoshis are returned to user A as change. These two copies of 5 “Satoshi” are a whole and are stored in two UTXOs with IDs abc456 and abc789 respectively. The above UTXO id and the number of “Satoshi” are only shown as examples. In actual situations, the minimum number of “Satoshi” sent is limited to 546 and the UTXO id is not expressed in this form.

In the above transaction, the circulation path of User A’s 10 Satoshis is:

  1. Mining produces 10 “Satoshi”, numbered [100, 110). Indicates that the 100th to 109th “Satoshi” is stored in the UTXO with the ID abc123, and its owner is user A.

  2. When A transfers money, 10 “satoshis” are divided into two parts, each with 5 “satoshis”. Used here”First come, first served”The principle is that the number ordering of “Satoshi” is determined according to their index in the transaction output. Assuming that the order of output is user A first, then user B, then the serial numbers of user A’s remaining 5 “satoshis” are [100, 105), which are stored in the UTXO with the id abc456, and user B’s 5 “satoshis” The sequence number is [105, 110) and is stored in the UTXO with id abc789.

How to implement metadata

Metadata for Ordinals inscriptions is not stored in a specific location. Instead, this metadata is embedded in the transaction’s witness data (witness data, witness field), which is why it is called an “inscription” because this data is “engraved” like an inscription on specific parts of the Bitcoin transaction. , and these data are attached to specific “Satoshi”. This inscription process is implemented through Segregated Witness (SegWit) and Taproot, which includes two stages: commit and reveal, and can inscribe any form of content (such as text, image or video) on the designated “satoshi”.

SegWit is a 2017 update that resulted in a soft fork of the Bitcoin blockchain. The update effectively separates Bitcoin transactions into two parts by adding a “witness data” section that can support arbitrary data.

Segregated Witness separates transaction and witness (signature) data into separate parts and enables arbitrary data to be stored in the witness part.

Technically, the implementation of Segregated Witness means that transactions no longer need to include witness data (and will not take up the 1MB of space that Bitcoin originally allocated for blocks). Instead, at the end of a block, an additional separate space is created for witness data. It supports arbitrary data transfers and has a discounted “block weight” that cleverly keeps large amounts of data within Bitcoin’s block size limits to avoid the need for a hard fork.

Implemented in November 2021, Taproot is a multi-faceted upgrade designed to improve Bitcoin’s privacy, scalability, and security. Taproot creates a system that makes it easier to store arbitrary witness data and relaxes the limits on how much arbitrary data can be placed in a Bitcoin transaction. The initial goal of this upgrade is to further enhance Bitcoin-based smart contracts, such as time-locked contracts, which are typically expressed in witness data.

Ordinals store metadata in a spend script in the Taproot script path.

First, due to the way Taproot scripts are stored, we can store inscription content in Taproot script path expenditure scripts, which have almost no restrictions on content, while also receiving discounts on witness data, making storing inscription content relatively economical. Since consumption of Taproot scripts can only be done from already existing Taproot output, Inscriptions are minted using a two-stage commit/reveal process. First, in the commit transaction, a Taproot output is created that promises a script containing the inscription content. Then, in the reveal transaction, a transaction is initiated by taking the UTXO corresponding to that inscription as input. At this time, the corresponding inscription content was made public to the entire Internet.

This approach greatly reduces the consumption of resources. If you do not use the Taproot script, the witness information is stored in the output of the transaction. In this way, as long as this output is not consumed, the witness information will always be stored in the UTXO set. In contrast, if P2TR is used, the witness information will not appear in the transaction generated during the commit phase, so it will not be written to the UTXO set. Only when this UTXO is consumed will the witness information appear in the transaction input during the reveal phase. P2TR enables metadata to be written to the Bitcoin blockchain, but never appears in the UTXO set. Since maintaining/modifying the UTXO set requires more resources, this approach can save a lot of resources.

What is BRC-20

Although the name of BRC-20 is very similar to Ethereum’s ERC-20, the technical differences between the two are actually significant. The holding status of ERC-20 tokens is saved on the chain, and network consensus can be obtained on the chain, while BRC-20 Just a special Ordinals protocol inscription, created by Twitter user @domodata on March 8, 2023, that utilizes ordinal inscriptions of JSON data to deploy token contracts, mint and transfer tokens. The deployed json is as follows:

{  

"p": "brc-20",//Protocol: Helps offline accounting systems identify and handle brc-20 events

"op": "deploy",//op operation: event type (Deploy, Mint, Transfer)

"tick": "ordi", //Ticker: identifier of the brc-20 token, 4 letters in length (can be emoji)

"max": "21000000",//Max supply: The maximum supply of brc-20 tokens

"lim": "1000"//Mint limit: The limit on the minting amount of brc-20 tokens each time

}

The corresponding ops are mint and transfer, and the two formats are almost the same. When op is Transfer, the transfer recipient of the inscription is the recipient of the “Satoshi” corresponding to the inscription. Therefore, the transfer of BRC-20 must be accompanied by the transfer of Bitcoin ownership and not just consumed as a handling fee.

BRC-20 implements a “first come, first served” mechanism. Repeated deployments and excessive mint are invalid. The centralized organization will deduce the current balance that the user should have based on each OP registered on the chain, and Make a judgment on the validity of the transaction.

In this process, the inscriptions are ‘attached’ to the transactional “Satoshi”. Bitcoin miners will not process these inscriptions. From the perspective of the chain, they are still no different from other “Satoshis”. They are all regarded as ordinary “Satoshis”. “Cong” is transferred.

Centralization problem of BRC-20

For the BRC-20 protocol, it treats the inscription as a ledger that records the deployment, minting, and transfer of BRC-20 tokens. Since smart contracts cannot be run on Bitcoin, BRC-20 tokens cannot query relevant information about the current token by running smart contracts. Therefore, BRC-20 uses off-chain queries, that is, using a centralized server to retrieve Bitcoin blocks, record the deployment, minting and transfer operations of all BRC-20 tokens to query the final balance of each user’s BRC-20 tokens.

Simply put, the BRC-20 ledger is decentralized and recorded on the Bitcoin chain, but the settlement process is centralized. There are currently two websites, brc-20.io and unisat.io, that support queries related to BRC-20 tokens.

The centralization of the settlement process may cause different platforms to have different results when querying a certain account balance. Although all operations are recorded on-chain, it is the responsibility of a client to verify these operations. If these centralized service providers do not disclose their verification rules, then there is actually no guarantee for the entire BRC-20 ecosystem.

In fact, on the evening of April 23, UniSat launched the BRC-20 trading platform, but due to vulnerabilities in the code library, it suffered a large number of double-spending attacks. The address bc1pwturekq4w455l64ttze8j7mnhgsuaupsn99ggd0ds23js924e6ms9fxyht initially minted the transferred Ordinals NFT and tried to transfer 5,000 ORDI and 35,000 ORDI to his own address out of thin air, and tried to sell the ordi minted out of thin air to other users. Unisat subsequently suspended access to the website and conducted an investigation, ultimately discovering that 70 transactions were affected.

Had Unisat not retrieved the error that night, the damage from the double-spend attack was estimated to be in excess of $1 million. How to ensure that the centralized server retrieval and verification is error-free is the most important issue that needs to be solved during the development of BRC-20.

Conclusion

The essence of the Ordinal inscription is: on the Bitcoin network with the help of aTaproot The script builds a simple accounting layer to count and record assets and data.

Since it only involves accounting, this means that there will be no script execution and verification processes similar to smart contracts, and it must be highly dependent on off-chain centralized management and reporting results.

Therefore, except for BRC-20, all Ordinals inscriptions must be based on offline services outside the Bitcoin network for state maintenance as long as they involve state transfer (such as transactions). If the underlying state service is unavailable or defective, it may lead to asset losses, because the Bitcoin network cannot prevent invalid inscriptions from being uploaded to the chain. The centralized platform must decide whose inscription is valid, and it will be valid on the platform.

This centralized trading and pricing method gives the centralized platform a significant opportunity for malicious behavior. Additionally, the combination of the logical paradox of the “first come, first served” inscription and the mechanism of miners prioritizing packaging based on mining fees allows miners and front-running robots to mint a large number of popular inscriptions before others, resulting in an unfair minting process.

However, predicting and assessing the development of new things is challenging. The introduction of the Ordinal inscription has undoubtedly sparked a debate within the Bitcoin community regarding the fundamental role and essence of Bitcoin. This discussion could potentially lead to a fork in Bitcoin, focusing on security and programmability. It seems that Pandora’s box is being opened.

Disclaimer:

  1. This article is reprinted from [小猪Go]. All copyrights belong to the original author [web3朱大胆]. 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.
Nu Starten
Meld Je Aan En Ontvang
$100
Voucher!