One article that takes you deeper into the Arc-20 and Brc-20 protocols

IntermediateFeb 01, 2024
This article goes into the details, advantages and disadvantages of the two protocols from a technical perspective.
One article that takes you deeper into the Arc-20 and Brc-20 protocols

Introduction

Recently, the introduction of the Arc-20 protocol has once again sparked a frenzy in the inscription market. This article will delve into the details and advantages and disadvantages of the two protocols from a technical perspective.

Why are there Brc-20 and Arc-20?

Bitcoin was originally designed to be a secure, stable, and reliable decentralized digital currency. However, due to its technical architecture and relatively less flexible scripting language compared to Ethereum, Bitcoin is not suitable for directly executing smart contracts.

Despite this, developers’ innovative ideas and bold attempts have brought prosperity to the Bitcoin ecosystem. One typical example is the Brc-20 protocol. The core idea of ​​the protocol is an experimental token form, centered on memes. Anyone can mint these tokens directly on the Bitcoin chain on a first-come, first-served basis without relying on smart contracts. The key feature of the Brc-20 token is its decentralized nature, which eliminates mechanisms such as private sales, pre-sales, and unlocking or staking. This ensures truly decentralized engagement.

In this context, the Arc-20 protocol has once again sparked a strong interest in inscriptions.

What is the UTXO model?

Brc-20 and Arc-20 protocols are both based on the Btc chain, so before we formally introduce the Arc-20 protocol and Brc-20 protocol, let’s briefly understand UTXO (unspent transaction output).

When we talk about Bitcoin, the UTXO (unspent transaction output) model is an important design concept. It is a type of account model used by Bitcoin, which is different from traditional balance models like bank accounts.

In the UTXO model, every Bitcoin transaction creates a series of unspent outputs, with each output representing a certain amount of Bitcoin. These unspent outputs are essentially unused units of digital currency, similar to paper bills or coins. When you receive Bitcoin, someone has actually created a new unspent output that is associated with your Bitcoin address. This output is the UTXO.

Let’s explain the UTXO model with a simple example:

If you have two transactions, one receiving 0.7 BTC and the other receiving 0.5 BTC, you will have two UTXOs, one worth 0.7 BTC and one worth 0.5 BTC. When you want to pay 1 BTC, you cannot simply use one UTXO, but you need to merge the two UTXOs into a new UTXO (with a total of 1.2 BTC), and then send 1 BTC to the recipient, with the remaining 0.2 BTC returned to yourself as change. However, the actual change may be less than 0.2 BTC because users need to pay a transaction fee to miners to ensure the smooth operation of the transaction.

Brc-20 Protocol Technical implementation

BRC-20 is an experimental standard that demonstrates the possibility of creating fungible tokens on layer 1 of Bitcoin by leveraging ordinal theory and inscriptions. The Ordinals protocol (the first token minted to the protocol’s standards) allows content, including text, images or videos, to be imprinted on Bitcoin’s smallest unit, Satoshi, thereby creating unique digital assets.

Ordinal theory is the key to implementing inscriptions on the BTC network.

Each Satoshi is essentially the same, and Ordinals have developed a Satoshi ordering protocol through narrative theory. This ordering is based on the mining of Satoshis and the order of their transaction inputs and outputs.

There are several different ways to represent ordinal numbers:

  • Integer notation: 2099994106992659 is an ordinal number assigned according to the order in which Satoshi is mined.
  • Decimal notation: 3891094.16797 The first number is the height of the block where Satoshi was mined, and the second number is the offset of Satoshi within the block.
  • Degree notation: 3°111094′214″16797‴. We’ll get to that later.
  • Percentile notation: 99.99971949060254%. Indicates the position of Satoshi in the Bitcoin supply, expressed as a percentage.

The degree expression contains four parts: A°B′C″D‴, and A, B, C, and D represent different meanings:

  • A: Period, numbered starting from 0. (Periodic cycle: Something magical happens every six halvings: the halving and the difficulty adjustment will happen at the same time. This is the so-called conjunction. The time period between the conjunctions is a cycle. It will happen about once every 24 years. Conjunction, the first conjunction should occur sometime in 2032.)
  • Block index during the halving era.
  • Block index during difficulty adjustment.
  • Index of Satoshi within the block.

Narrative theory determines the order of a Satoshi through degree expression, and defines different rarity levels for each Satoshi through the order, thereby achieving the uniqueness of each Satoshi

  • Common: Any non-first Satoshi in the block.
  • Uncommon: The first Satoshi of each block.
  • Rare: The first satoshi of each difficulty adjustment cycle.
  • Epic: The first satoshi in each halving epoch.
  • Legendary: The first satoshi of each cycle.
  • Myth: The first Satoshi in the genesis block.

for example, for example, an existing degree is expressed as 1°1′0″0‴, where

  • 1°: represents the second cycle
  • 1′: represents the first block that is not the halving cycle
  • 0″: represents the first block of difficulty adjustment
  • 0‴: represents the first satoshi of the block

With the rarity definition above, this Satoshi is defined as rare stoshi.

The general process is as follows:

How is it implemented through code in Ordinals?

py# Calculate the narrative (reward) of a block given a height

def subsidy(height):

return 50*100_000_000 >> height // 210_000

This function is used to calculate the reward for a Bitcoin block of a given height, where 50*100_000_000 is the starting reward of Bitcoin, >> is the right shift operator, equivalent to dividing by 2 integer divisions. This function returns an integer representing the reward amount for a block at a given height.

Calculate the ordinal number of the first reward for a block of a given height

def first_ordinal(height):

start = 0

for h in range (height):

start += subsidy(h)

return start

This function calculates the ordinal number of the first reward for a block at a given height. Calculate the total number of rewards from the first block to a given height by iterating through the heights and accumulating the rewards for each block, resulting in the ordinal number of the first reward.

Assign ordinal number to given block

def assign_ordinals(block):

first = first_ordinal(block.height)

last = first + subsidy(block.height)

coinbase_ordinals =list(range(first, last))

Assign ordinal number to given block

def assign_ordinals(block):

first = first_ordinal(block.height)

last = first + subsidy(block.height)

coinbase_ordinals =list(range(first, last))

for transaction in block.transactions[1:]:

ordinals = []

for input in transaction.inputs:

 ordinals.extend(input.ordinals)

for output in transaction.outputs:

 output.ordinals = ordinals[:output.value]

 of the ordinals[:output.value]

coinbase_ordinals.extend(ordinals)

for output in block.transactions[0].outputs:

output.ordinals = coinbase_ordinals[:output.value]

of the coinbase_ordinals[:output.value]

This function is used to assign an ordinal number to a given Bitcoin block. It first calculates the ordinal range of the first and last rewards of the block. Next, it iterates over each transaction in the block, assigning an ordinal number to each output. Finally, the outputs of the transaction are assigned ordinal numbers to ensure that all satoshis in the entire block have unique ordinal numbers.

In short, through ordinal theory, originals make each essentially the same Satoshi unique through processing, and define rare familiarity for each Satoshi through rules, realizing collection attributes or formulating rules to suit gameplay.

Use Case

  • Interesting: Unique and interesting protocols will bring prosperity to the Bitcoin ecosystem once again.
  • Asset Issuance: BRC-20 tokens can serve as digital representations of assets, equity, or other fungible entities. These can be stablecoins, utility tokens, or meme-based tokens.
  • dApp Integration: Developers can integrate BRC-20 tokens into decentralized applications that utilize the Bitcoin network. Their applications range from generating income and collateralized loans to staking for equity.
  • Asset Tokenization: The brc-20 standard facilitates the tokenization of any asset or interest, opening many possibilities such as token-based community or DAO voting.
  • Exchange mechanism: brc-20 tokens can be conveniently exchanged and traded on the first layer of the Bitcoin network through various platforms. While they are currently accessible via the order book, plans to integrate them into liquidity pool exchanges have recently surfaced.

Arc-20 Technical implementation

The Atomicals protocol is a simple and flexible protocol for minting, transferring, and updating digital objects (traditionally known as non-fungible tokens) on a blockchain with unspent transaction outputs (UTXOs) such as Bitcoin. An Atomical (or “atom”) is a way of managing the creation, transfer, and updating of digital objects - essentially a digital ownership chain defined by some simple rules.

Arc-20 adopts the colored coin model, which means that an Arc-20 token must have a satoshi support, unlike Brc-20 tokens that are differentiated by ordering. Since Arc-20 tokens are entirely based on satoshis, they can be split and merged (similar to UTXOs mentioned at the beginning of the article) and can be directly transferred over the Bitcoin network.

For example, using the Atomicals protocol, we can define 100 satoshis as 100 “movie tickets”, and users can use one of these 100 satoshis to pay at a movie theater that supports the Atomicals protocol, acting as a movie ticket.

However, miners and the Bitcoin network cannot know which UTXOs have been “Atomicalized”, which may mistakenly consider Arc-20 tokens as miner fees. To solve this issue, Atomicals instructs that each Arc-20 token should be the first output of a transaction to avoid accidental token destruction.

Use Case

  • Digital collectibles, media and art
  • Digital identity, authentication and token gating content.
  • Web hosting and file storage
  • Point-to-point swaps and atomic swaps
  • Numeric namespace allocation
  • Virtual land and title registration
  • Dynamic objects and states in the game
  • Social media profiles, posts and communities
  • Anywhere security and decentralization are key issues. With military-grade security and verification requirements.

Brc-20 vs Arc-20

Next, we will analyze and compare the similarities and differences between the two protocols.

Brc-20

The agreement is roughly divided into three steps

  1. The deployer needs to write the relevant information of the token to the BTC chain according to the protocol format.

{

“p”: “brc-20”,

“on”: “deploy”,

“tick”: “ordi”,

“max”: “21000000”,

“lim”: “1000”

}

  1. The indexer reads data related to tokens on the chain
  2. The off-chain ledger records the relevant balances of tokens and processes transfers

Since the token information itself cannot be recognized by BTC when the deployer deploys the token, an indexer is needed to obtain relevant data on the chain and use this data to create a ledger off the chain to record relevant history and process related Operate and perform data updates.

The off-chain indexer needs to accurately capture and update the offline ledger for each token operation. However, similar to the blockchain, as the number of transactions increases, the data stored by nodes will become larger and larger. Ensuring the integrity of the ledger and finding the information that needs to be modified within the vast amount of data will become a challenge for BRC-20.

Arc-20

Similarly, the Arc-20 protocol also needs to record relevant information according to the format on the BTC chain when deploying tokens.

program.command(‘init-dft’)

.description(‘Initialize fungible token (FT) atomical in decentralized issuance mode’)

.argument(‘<ticker>’, ‘string’)

.argument(‘<mint_amount>’, ‘number’)

.argument(‘<max_mints>’, ‘number’)

.argument(‘<mint_height>’, ‘number’)

.argument(‘<file>’, ‘string’)

.option(‘—rbf’, ‘Whether to enable RBF for transactions.’)

.option(‘—funding <string>’, ‘Use wallet alias wif key to be used for funding and change’)

.option(‘—satsbyte <number>’, ‘Satoshis per byte in fees’, ‘15’)

.option(‘—mintbitworkc <string>’, ‘Whether to require any bitwork proof of work to mint. Applies to the commit transaction.’)

.option(‘—mintbitworkr <string>’, ‘Whether to require any bitwork proof of work to mint. Applies to the reveal transaction.’)

.option(‘—bitworkc <string>’, ‘Whether to put any bitwork proof of work into the token mint. Applies to the commit transaction.’)

.option(‘—bitworkr <string>’, ‘Whether to put any bitwork proof of work into the token mint. Applies to the reveal transaction.’)

.option(‘—parent <string>’, ‘Whether to require a parent atomical to be spent along with the mint.’)

.option(‘—parentowner <string>’, ‘Wallet owner of the parent to spend along with the mint.’)

.option(‘—disablechalk’, ‘Whether to disable the real-time chalked logging of each hash for Bitwork mining. Improvements mining performance to set this flag’)

.action(async (ticker, mintAmount, maxMints, mintHeight, file, options) => {

…..

}

In the atomicals-js cli source code, you can find the instructions for initializing a token. The parameters that need to be recorded on the chain are:

ticker: token name

mint_amount: total amount of mint

max_mints: the number of mints in a single time

mint_height: specifies the height of the block to start mint

file: related metadata

But unlike Brc20, Arc20 adopts a colored currency model. After the token-related information is entered into the BTC chain, the protocol will anchor the token with Sats:1 token = 1 sat。

At the same time, the use of the colored currency model allows users to conduct transactions directly through the BTC network instead of off-chain ledgers. Because the token balance is consistent with the satoshis in UTXO, the related changes in the token can be intuitively reflected on the chain. . The indexer in Arc-20 is only used to read the relevant deployment information of tokens on the chain and verify which tokens are compliant with the Arc-20 protocol.

Conclusion

The design structure of Brc-20 relies more on off-chain ledgers, while Arc-20 is more in line with the characteristics of Btc and is more decentralized compared to Brc-20. However, the colored coin model prevents Arc-20 from completing the issuance of meme coins, as meme coins often have a high total token supply, and the feature of 1 token = 1 sat requires a large amount of Btc to be consumed when issuing meme coins.

author:@YanAemons

Disclaimer:

  1. This article is reprinted from [medium]. All copyrights belong to the original author [@YanAemons]. 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