Skip to content

Ordinal inscription

zhouop0 edited this page Nov 8, 2023 · 5 revisions

What is the Ordinals, Ordinals Inscription and BRC-20

What is the Ordinals ?

Ordinals are a numbering scheme for satoshis that allows tracking and transferring individual sats. These numbers are called ordinal numbers. Satoshis are numbered in the order in which they're mined, and transferred from transaction inputs to transaction outputs first-in-first-out. Both the numbering scheme and the transfer scheme rely on order , the numbering scheme on the order in which satoshis are mined, and the transfer scheme on the order of transaction inputs and outputs. Thus the name, ordinals .

How sats numbered ?

It uses Bitcoin`s unique block process and UTXO model to give each sat a unique number.

UTXO Model

UTXO(Unspent Transaction Output) is a ledger model in which each transaction in the Bitcoin system produces some output, such as the output of a transfer transaction is the recipient's Bitcoin address and the amount transferred. These outputs are stored in the UTXO collection and are used to record the output of unspent transactions.

The UTXO model has the advantage of greater security and privacy, as it does not have a centralized account record and the traditional account model can expose account balance information.

The disadvantage of the UTXO model is that it increases the transaction validation cost and storage cost. Each time you make a transaction, you need to verify that the payment and receipt of the transaction are legitimate, and you also need to store a large amount of UTXO information.

So any transaction can always be traced from the Input to the Coinbase transaction and then back to the serial number of each coin when it was mined.

when we say how many bitcoins we have, we actually mean the number of bitcoins specified in those UTXOs that we own, so we want to count the number of BTC for an address:

  1. Scan from Genesis block;
  2. When an output of a transaction is the specified address, the balance increases;
  3. When an input of a transaction is the specified address, the balance is reduced;

Relationship between sat and UTXO

Note that every sat is not a UTXO! A UTXO is the smallest transaction unit that cannot be redivided, so sat can only exist in a UTXO that contains a certain range of sats and can only split the sats number when a UTXO is spent to produce a new output

For example, if I get 50 BTC in Genesis block or CoinBase block, the corresponding Input and Output are

### inputs //nil
### outputs : addr_a:[0 -> 4,999,999,999] sats

If I make a transfer of 20BTC to address B, the UTXO set will show, where input is the output of the previous transfer

### inputs 
addrA: [0 -> 4,999,999,999] sats
### outputs # 30 btc to adrA, index=0
addrA: [0 -> 2,999.999.999] sats
# 20 btc to addrB, index1
addrB: [3,000,000,000 -> 4,999,999,999] sats

The sats consumption order is based on the FIFO" First-In-First-Out "principle, in the case of the same transaction costs, the earlier UTXO will be used in the transaction priority over the later UTXO.

ordinals number

Ordinal numbers have a few different representations:

  • Integer notation : 2099994106992659 The ordinal number, assigned according to the order in which the satoshi was mined.
  • Decimal notation : 3891094.16797 The first number is the block height in which the satoshi was mined, the second the offset of the satoshi within the block.
  • Degree notation : 3°111094′214″16797‴. We'll get to that in a moment.
  • Percentile notation : 99.99971949060254% . The satoshi's position in Bitcoin's supply, expressed as a percentage.
  • Name : satoshi. An encoding of the ordinal number using the characters a through z.

What's interesting about this notation is that it artificially creates a scarcity for the sat based on the cyclical nature of Bitcoin itself:

A°B′C″D‴
│ │ │ ╰─ Index of sat in the block
│ │ ╰─── Index of block in difficulty adjustment period
│ ╰───── Index of block in halving epoch
╰─────── Cycle, numbered starting from 0

more information, you can see ordinal handbook.

What is the Ordinals Inscription?

Before discussing ordinals inscription, let's take a look at two major upgrades to Bitcoin's expansion: SegWit and Taproot

SegWit

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.

The original purpose of witness data is to:

  1. Bypass the strict restrictions of block size limits
  2. Allow optional and arbitrary data transfers
  3. Prevent unintentional trading plasticity

Technically, the implementation of SegWit means that transactions no longer need to include witness data (not taking up the 1MB of space that Bitcoin originally arranged for blocks).** Instead, at the end of a block, an additional separate space is created for the 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 limit to avoid the need for a hard fork.

Ordinals inscription is to hide the inscription data in the witness data.

Taproot

Taproot, implemented in November 2021, is a multifaceted upgrade designed to improve the privacy, scalability, and security of Bitcoin.Taproot creates a system that makes it easier to store arbitrary witness data and loosens restrictions on how much arbitrary data can be placed in a single Bitcoin transaction. The initial goal of this upgrade is to further strengthen Bitcoin-based smart contracts, such as time-locked contracts, which are often expressed in witness data.**

These updates are a key enabler for Ordinals NFT, which stores NFT data in spent script in the Taproot script path. This upgrade makes it easier to structure and store arbitrary witness data, laying the foundation for the "ord" standard. With the relaxation of data requirements, assuming that a transaction can fill an entire block with its transaction and witness data - up to the 4MB block size (witness data space) limit - vastly expands the types of media that can be placed on the chain.

The priceple of Ordinals inscription is that using tapscript that is never executed to keep statistics and records of assets and data which builds a simple bookkeeping layer on the bitcoin network.

What is the BRC20?

The name of the BRC-20 looks like Ethereum's ERC20 at first glance, but in fact the technical difference between the two is very large, and the state of the ERC-20 token is saved on the chain, and the network consensus can be obtained on the chain. While BRC20 is a JSON-formatted inscription with the help of the Ordinals protocol, which only defines the deployment, minting and transfer behavior of brc-20 tokens, and the status of BRC-20 tokens is maintained by the off-chain service.

{
	"p":"brc-20", //protocol: Helps offline systems identify and process brc-20 time
	"op":"deploy",//op operation: Time type (deploy, Mint, Transfer)
	"tick":"ordi", //Tricker: brc-20 token identifier, 4 letters in length 
	"max":"21000000", ///Max supply
	"lim": "1000" //Mint limit
}

The op also has Mint and Transfer, the two formats are almost the same, of course, if you are familiar with transactions on Ethereum, it will feel strange. This is because when the transfer transaction takes effect, it is when the sat to the inscription content is traded, so whoever receives the sat to the inscription is the receiver, so the transfer of brc-20 must be accompanied by the transfer of Bitcoin ownership (not just as a fee to be consumed). The centralized organization derives the current balance that the user should have based on each op registered on the chain. For example, the client software (indexer) such as unisat. io is obtained according to mint and transfer events. For example, if UTXO contains the mint inscription, it is added for the first owner, transfer deducts the balance from the initiator's address, and the recipient's address adds the balance. In this process, the inscription is' attached 'to the transaction (sat), Bitcoin miners will not deal with these inscriptions, from the chain point of view and other sat is still no difference, they are as ordinary sat to transfer.