Annexe

CBRC-20 Metaprotocol Rules

General Rules

  1. Ordinal Client v0.10+: CBRC-20 is ONLY compatible for indexing on the ord client v0.10+. ord v0.9 will not work for CBRC-20 as metadata and metaprotocol fields were not yet included.

  2. MIME Type Flexibility: Any MIME type can be used for CBRC-20 token operations.

  3. Metaprotocol Field Syntax:

    • For deploy operations, the field must start with cbrc-20:deploy and include a CBOR file with the following properties:
      • tick: Ticker symbol of the token.
      • max: Maximum supply of the token.
      • lim: (Optional) Mint limit per ordinal. Defaults to max if not specified.
      • dec: (Optional) Decimal precision. Defaults to 18 if not specified.
    • For mint or transfer operations, the syntax is <metaprotocol>:[op]:[tick]=[amt].
      • [metaprotocol]: Specifies cbrc-20.
      • [op]: Operation type (mint or transfer).
      • [tick]: Ticker symbol of the token.
      • [amt]: Amount for the operation.
  4. Metadata Field:

    • Required for deploy inscriptions.
    • Contains token-related information in CBOR format.
  5. Decimals and Supply:

    • Decimal precision is capped at 18.
    • Maximum supply is limited to uint64_max.
  6. Ticker Rules:

    • Ticker symbols MUST be 4 bytes wide and are case-insensitive.
    • The first deployment of a ticker symbol holds exclusive claim to it (First is First).
  7. Balance Management:

    • Wallets maintain an overall balance and an available balance.
    • Minting increases both overall and available balances.
    • Transferring decreases the available balance of the sender and increases the receiver’s balance.
  8. Validity of Operations:

    • A valid transfer function must not exceed the available balance when inscribed.
    • Balance restoration involves transferring the transfer function inscription back to oneself.
  9. One-Time Use of Transfers:

    • Each transfer inscription is valid for a single use only.
  10. Prohibited Actions:

    • Sending inscriptions to non-ordinal compatible wallet taproot addresses is not allowed.
    • Transferring mint functions does not result in a balance change.
  11. Priority Assignment:

    • In events occurring in the same block, priority is assigned based on confirmation order.

CBOR Info

How to Use the Cy[bord] JSON->CBOR Encoding Script

This should help walk you through using a Node.js script we made to encode JSON data into CBOR format and append it to a .cbor file. This is a crucial step for the CBRC-20 deploy operation.

Prerequisites

Steps

  1. Setup Your Project Directory:
  • Create a new folder on your computer for your project.
  • Make a new file in this folder that contains the following:
const cbor = require("cbor-js");
const fs = require("node:fs/promises");

async function main() {
  const data = await fs.readFile("./deploy.json", "utf-8");
  const encoded = cbor.encode(JSON.parse(data));

  await fs.appendFile("./deploy.cbor", Buffer.from(encoded));
}

main();
  • Save this file as <script-file-name.js>.
  1. Prepare Your JSON File:
  • Create a JSON file (e.g., deploy.json) in the same directory as your script. This file should contain the data you want to encode in CBOR format, for example:
{
  "tick": "BORD",
  "max": "21000000",
  "lim": "1000",
  "dec": "8"
}
  1. Install Dependencies:
  • Open a terminal or command prompt.
  • Navigate to your project directory using the cd command.
  • Run npm init -y to create a package.json file.
  • Install the cbor-js library with npm install cbor-js.
  1. Run the Script:
  • Ensure your JSON file has the correct data and is saved.
  • In the terminal, execute the script by running node <script-file-name.js>, replacing <script-file-name.js> with the name of your JavaScript file.
  1. Check the Output:
  • After running the script, a new file (e.g., deploy.cbor) will be created or updated in your project directory.
  • This file contains the CBOR-encoded data from your JSON file.

Notes

  • The script reads the JSON file, encodes its contents to CBOR format, and then appends this encoded data to a .cbor file.
  • Make sure the names of your JSON and CBOR files in the script match the actual files in your directory.

Can I Use an Ordinal-Based Implementation of CBOR ?

Indeed you can. A user has kindly submitted a few lines of code that allow a CBOR format to be encoded or decoded natively in JS on the browser side.

FAQ

What is CBOR?

CBOR (Concise Binary Object Representation) is a data serialization format similar to JSON (JavaScript Object Notation), but it is binary rather than text-based. Designed to be compact and efficient, CBOR is particularly useful in environments where bandwidth and storage are at a premium, like in blockchain technology.

While CBOR and JSON serve similar purposes in data serialization, they differ significantly in their representation. JSON is a text-based format that's human-readable, while CBOR is a binary format that prioritizes compactness and efficiency. Both can represent similar types of data structures like arrays, objects (maps in CBOR), and basic value types (strings, numbers, booleans).

CBOR vs. JSON

  1. What are the main advantages of CBOR over JSON?

    • Size Efficiency: CBOR’s binary nature makes it more compact than JSON, which is critical in blockchain applications where data size directly impacts transaction costs.
    • Speed: Parsing CBOR requires less computational power, leading to faster processing times.
    • Flexibility: CBOR supports a wider range of data types, allowing for more precise and versatile data representation.
  2. Is it cheaper to inscribe CBOR data in the Ordinal envelope compared to inscribing a JSON/txt file? Why?

    • Yes, it is generally cheaper. This cost-effectiveness stems from CBOR's compact size, meaning that less data is inscribed on the blockchain. Since blockchain fees are often calculated based on the amount of data in a transaction, the smaller size of CBOR-encoded data results in lower fees.
  3. What does CBOR offer for storing data on Bitcoin in the witness feature of Taproot through Ordinal Inscriptions, compared to JSON?

    • Efficient Use of Space: CBOR's compact format allows for more data to be stored within the limited space of Bitcoin's witness feature.
    • Cost-Efficiency in Transactions: Smaller data size translates to lower transaction fees in Bitcoin, which is crucial for Ordinal Inscriptions.
    • Better Handling of Complex Data: CBOR’s diverse data type support makes it more suitable for complex and nuanced data structures required in advanced Bitcoin applications.

PGP

Key-ID: 61E0493DD2FF7A69

-----BEGIN PGP PUBLIC KEY BLOCK-----

mI0EZZGh/gEEAMPmZYppbCqngfU3iMFfJD10Cc9/ZOuuBex70T0wrM6wg1VIdXKR
jeyWVQXdz5XQPQzDliMFYkIfy3zt0wC4H3+ZHXyH2EDADwhoCRrEzOeOyWT/Tddy
bGFigu5PnE1TqtWbg5UsOTPivUbdZfDyY/7x+7aEnzPAqCb9noMzwBrhABEBAAG0
QkN5Ym9yZCAoQ3lib3JkIC0gbWV0YXByb3RvY29sIDo6Y2JyYy0yMCkgPG9yZGlu
YWxjeWJvcmdAcHJvdG9uLm1lPojOBBMBCgA4FiEEm1jMElFB2S3zmRqeYeBJPdL/
emkFAmWRof4CGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQYeBJPdL/emkI
EAQAoTqsJLxRoZVXN8jnrTlsDIMBdZNXC63MVRiGQGqUuEyejUdZzKOJdAwHguqO
3jjFIFhuDgZDHVWFKRCxOn6oGy+aDbWdU8ewhXcVc35fW2SYp7mz6XxM6LG9vK4+
AcmQYD+92BkABpZrVErGThvrL9LYZb0Dkl0YAnAHZcXl9xu4jQRlkaH+AQQAoyeo
CWMH+bnjIq7jp2bnN4S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