HomeEspañolFrançais

Demystifying RGB: Bitcoin (BTC) Embraces DeFi and NFTs with a Touch of Privacy

RGB is a Layer 2 protocol for Bitcoin (BTC) that paves the way for smart contract creation, providing new opportunities for the blockchain, such as decentralized finance (DeFi) applications, non-fungible tokens (NFTs), and stablecoins. What truly sets RGB apart is its native privacy feature. Let's explore how this infrastructure facilitates DeFi development on Bitcoin.

30th July 2023
13 minutes to read
This article is a translation of an article from Cryptoast.fr, which you can find here.

Is DeFi as decentralized as we think?

For a few years now, decentralized finance (DeFi) has occupied a significant place in the world of cryptocurrencies.

While Bitcoin's main goal is to disintermediate monetary exchanges, DeFi takes it a step further, aiming to disintermediate the finance.

Numerous innovative protocols have emerged, offering decentralized alternatives to services originally provided by centralized financial institutions.

However, as new infrastructures like Polygon (POL) or Solana (SOL) are created and Ethereum (ETH) transitions to a proof-of-stake (PoS) system, it is legitimate to question the decentralization of these networks and the DeFi protocols built on them.

If these protocols rely on weakly decentralized or censorable blockchains, it may be more accurate to refer to them as "finance without banks" rather than truly decentralized finance.

Moreover, recent controversies, such as the Arkam Intelligence (ARKM) incident, raise a question : How resistant a network is to censorship if we can easily link an individual to their on-chain wallets?

While BTC on the Bitcoin blockchain cannot be intercepted, if a government hostile to Bitcoin could link an individual to their wallets, they could sanction the user without even gaining access to their BTC.

Considering these factors, it becomes evident that a decentralized and confidential network is necessary, and that's where RGB comes into play.
Get 0.5% off Bitcoin purchases at Relai App with code: MARIUSAAB

What is RGB, and how do its smart contracts work?

RGB, which stands for "Really Good for Bitcoin," is a smart contract protocol that operates as a second-layer technology above Bitcoin (BTC) or as a third layer above the Lightning Network.

RGB boasts characteristics such as greater scalability and confidentiality compared to Bitcoin. This means it can confirm transactions faster and does not disclose any information that would later become visible on a blockchain.

Indeed, RGB is neither a blockchain nor a rollup; instead, it is a Directed Acyclic Graph (DAG), sometimes colloquially referred to as a "state machine."

The main goal of this DAG is to offload a maximum amount of work and data from the Bitcoin blockchain. This is done for various reasons: to avoid overloading the Bitcoin network, to prevent the rapid increase in the size of its blockchain, to create a new environment conducive to the development of smart contracts, and to enhance transaction confidentiality.

Although RGB does not require tokens to function, its smart contracts enable the creation of various assets and services, including fungible and non-fungible assets (NFTs), decentralized finance (DeFi), Decentralized Autonomous Organizations (DAOs), decentralized identities, and much more.

Several second-layer solutions exist on Bitcoin today, but RGB has the potential to stand out from the rest:
-Liquid (L-BTC) - a second-layer solution enabling the creation of various digital assets but is more centralized than RGB.
-Stacks (STX) - a separate blockchain, which is also more centralized than RGB.
-Taproot Assets protocol - that only allows asset creation by leveraging the Taproot update.

Client-side validation

Based on the ideas of Peter Todd, client-side validation is the concept that transaction validation should be performed by the future owner of the assets and rights being exchanged.

Client-side validation implies that owners and smart contracts must have access to the "stash." The "stash" represents the history of proofs of past transactions and should be transferred to the new owner to verify the validity of transactions.

As a result, smart contracts and transactions are validated within the wallets themselves and not on a network of nodes.

Wallets create the new state and prepare data compression in a Merkle tree before anchoring the state in a Bitcoin transaction or a Lightning Network transaction; this is referred to as the "commitment."

The scalability of RGB is truly remarkable. In fact, it would be possible to gather 100,000 states from different protocols into a single commitment and thus accommodate all the contracts of Ethereum (ETH) using just a few on-chain commitments. Thanks to RGB, Bitcoin has the theoretical potential to process millions of contracts per second, all while improving privacy.

As for the storage of stash, it is indeed possible to rely on a third party to keep our data for us. However, just as with a custodial wallet where one might say, "not your keys, not your crypto", in this case, it's "not your keys, not your stash".

Client-side validation differs from the consensus system of a blockchain because, as shown in the following illustration, only Bob needs to verify the validity of his own properties. Unlike a blockchain where each transaction must be checked and validated by the entire network, which is more energy-intensive and slower.
The Life of a Smart Contract in RGB
Each transaction creates a new state. Thus, if Bob owns 10 RGBTC (the native BTC wrap on RGB), he will be considered the "state owner" of his 10 RGBTC states.

Now he can view the history of his tokens from their creation (the genesis) to ensure their authenticity, but no other information is disclosed to him. He cannot know how many RGBTC Alice and Jeanne held at the time of purchase or how much they bought from the previous person.

In a blockchain system, it is in everyone's interest to verify each transaction. If a fraudulent transaction is confirmed, it could impact the security of the entire network.

In a state machine, Bob only validates the transactions that interest him and does not need to know that Alice received USDT from Jeanne.


The Single Use Seals

Also based on the ideas of Peter Todd, "single-use seals" are used to link each new RGB state to a Bitcoin Unspent Transaction Output (UTXO).

These seals could be compared to the seals on a letter. The content of the letter represents the new state, and once the seal is closed, the content cannot be changed without breaking it.

If the seal is broken, it becomes unusable, and the transaction will no longer be valid.

These seals ensure that a transaction can only be spent once within the RGB system. Publishing them on the Bitcoin blockchain further strengthens this mechanism, benefiting from its protection against double spending.

While RGB could be linked to any information publishing system, it turns out that Bitcoin is the best tool for storing these transaction proofs.

The RGB Schema

The "Schema" is the set of rules governing a smart contract on RGB. Each developer can initialize a different schema, defining the characteristics they consider necessary for the proper functioning of the smart contract under construction.

The schema represents the entirety of the smart contract's rules which will be stored in the stash. If a token is issued in compliance with this schema, it will be recognized and accepted by compatible smart contracts. However, if it does not adhere to the schema's rules, it will not be processed.

This schema system allows for the improvement or modification of a smart contract's rules without having to change the code across the entire RGB network. The schema provides a structure and clear constraints to ensure compatibility and security of RGB assets.

From a technical perspective, the schema defines various aspects, including the types of data retained, the types of rights granted to participants, and how rights and properties can be transferred.

The schema is defined in the first state, meaning at the genesis of the smart contract. The individual who created the genesis will be called the "smart contract issuer" or the issuer of the smart contract.
Illustration of the Life of a Smart Contract on RGB
Thus, the life of a smart contract in RGB can be likened to the expansion of the universe. The genesis of the smart contract would correspond to the Big Bang, a crucial moment when all rules and laws are established in the schema.

Each point represents a celestial body, corresponding to the properties of the users. Each line represents the movements of celestial bodies, corresponding to properties that separate and converge. Just like the expanding universe, smart contracts are immutable, and their lives continue to expand endlessly.

AluVM:

AluVM is RGB's virtual machine, representing an essential advancement in optimally connecting RGB smart contracts to the Bitcoin network.

Developed in Rust, AluVM provides greater accessibility to developers, making it easier to create and manage smart contracts in the RGB ecosystem. This approach improves the efficiency of RGB's development.
Comparative Table of Different Virtual Machines

RGB-20: Fungible Assets

RGB-20 is the name of the interface used as a foundation for creating smart contracts for fungible assets, such as governance tokens, cryptocurrencies comparable to currencies, stablecoins, and more.

For instance, RGBTC, the representation of BTC on RGB, is an RGB-20 token.

Please note that a burn or mint mechanism can be added during the creation of a new token, and this mechanism must be included in the Schema.

RGB-21, Non-Fungible Assets

RGB-21 is the name of the interface used as a foundation for creating smart contracts for non-fungible assets (NFTs). Leveraging the features of RGB, RGB-21 offers an innovative and more efficient approach to storage, privacy, and monetization of content.

With RGB-21, there is no longer a need to rely on costly blockchain storage or use centralized data management solutions like Microsoft Azure, AWS, etc. Instead, all data is stored by the owners themselves.

One of the key features of RGB-21 is its ability to allow creators to sell access rights to the content one or multiple times while preserving ownership and control over it. This eliminates the need for expensive intermediaries, enables creators to maximize their profits, and allows anyone to purchase rights to a file.

RGB-22, Decentralized Digital Identities

RGB-22 is the name of the interface used as a foundation for creating smart contracts for decentralized digital identities (DID). The privacy features of RGB are well-suited for this use case.

This interface was conceived even before the network was finalized, becoming a clear objective for the developers. RGB-22 could enhance the security of our personal data.

Decentralized digital identities are valuable as they help address the issues related to the centralization of personal data on the Internet.

Currently, platforms collect, use, and sell our data to create detailed user profiles, enabling them to target advertisements based on our personalities.

By developing decentralized digital identity standards, it becomes possible to regain control over our information while ensuring better protection of our privacy.

Carbonado

Created by the team behind the NFT platform DIBA, Carbonado is a decentralized storage system designed to replace centralized storage systems such as Microsoft Azure, AWS, etc.

The goal of this storage system is to archive consensus data in an encrypted and durable manner.

Carbonado shares similarities with the Nostr relay system, with which it is compatible, but its primary objective is to store and encrypt end-to-end the RGB data held in wallets (smart contracts, stashes, invoices, files related to RGB-21, etc). The development of Carbonado is still ongoing.

Bifrost

The Bifrost protocol plays a crucial role in implementing RGB functionalities on the Lightning Network. Bifrost is an extension of the Lightning Network that enables the transmission of client-side validation data.

Thus, Bifrost allows RGB-20 transactions to occur on the Lightning Network and paves the way for more efficient features such as decentralized exchanges (DEX), decentralized finance (DeFi) applications, etc.

While Bifrost is not directly integrated into RGB, it makes mobile RGB wallets compatible with the Lightning Network. Bifrost enables users to interact with the Lightning Network without running a full node, improving the user experience and expanding the use cases for RGB.

Independent of RGB, Bifrost was created to make the Lightning Network compatible with miniscript and the Taproot update.

Storm

Storm, which works in tandem with the Bifrost protocol, also plays a crucial role in facilitating the transmission of messages and decentralized storage on the Lightning Network.

Storm enhances decentralized data storage by utilizing special payment channels and RGB smart contracts.

Indeed, it provides solutions for compensating storage providers, protecting against data loss, and ensuring that payments are made fairly.

Who is behind the development of RGB?

The original idea, conceived by Giacomo Zucco in 2016, was to create an asset system that is not based on the Bitcoin blockchain, drawing inspiration from Peter Todd's earlier ideas on client-side validation and single-use seals.

However, in 2019, RGB was rethought and restructured from scratch as part of the LNP/BP (Lightning Network Protocol/Base Protocol) standards effort, transforming into what it is today.

Dr. Maxim Orlovsky of Pandora Core AG became the lead designer and contributor to the RGB protocol. He played a vital role in the design and implementation of over 95% of the current code and underlying standards.

The design of RGB and its restructurings were significantly influenced by the community, which made significant contributions. Over 50 individuals and organizations played a crucial role in the design, review, and evaluation of the RGB protocol.

Furthermore, Dr. Maxim Orlovsky and Giacomo Zucco also had discussions with prominent cryptographers, distributed systems specialists, and game theorists such as Adam Back, Peter Todd, and many others. They provided important ideas and suggestions for the design of the RGB protocol.

Finally, RGB has been adopted by various companies and projects, including HodlHodl, Bitfinex, Tether Inc, Condensat Technologies, and others. These entities have shown financial commitment to the integration of RGB and ongoing evaluation of the protocol.
Get 0.5% off Bitcoin purchases at Relai App with code: MARIUSAAB

How to Use RGB?

RGB is functional, but its development is not yet fully completed. However, there are already some applications that you can test right now. Here's a non-exhaustive selection:

-MyCitadel: An open-source hot and cold wallet for Bitcoin developed by Dr. Maxim Orlovsky. It is compatible with various platforms such as Linux, MacOS, and Windows, and allows interaction with RGB.
-BitMask: Another hot wallet compatible with RGB designed for Bitcoin and the Lightning Network. It is available as a web application or a browser extension.
-Diba: The first NFT marketplace using RGB and the Lightning Network. Although still in beta, you can test it on the Bitcoin testnet.
-RGBex: The RGB explorer, similar to Etherscan for Ethereum. Due to the network's privacy, only limited information is visible.

In addition, RGB already hosts certain assets such as RGBTC, smart contract issuers like the LNP/BP Standards Association, interfaces like RGB-20, schemas like NIA (Non-inflatable fungible assets), as well as companies participating in the network's development, like Bitfinex.

To discover other applications, such as decentralized finance (DeFi) or decentralized identity (DID) solutions, you will need to wait a bit longer. The development of RGB is progressing, and new opportunities will undoubtedly arise as the project evolves.

Our opinion on RGB and its relevance for Bitcoin

The objective of RGB is to extend Bitcoin's consensus beyond its main chain, paving the way for new applications. With its unique features, RGB could become one of the most useful and widely used Bitcoin overlays.

RGB's structure provides it with better scalability than the Bitcoin blockchain. On one hand, client-side validation allows each smart contract to act as an independent "shard," avoiding validation by the entire network. On the other hand, leveraging the Lightning Network enables almost instantaneous transactions.

RGB's DAG enhances user sovereignty by giving them full control over their rights and assets.

By only recording a transaction's encryption on the lower technological layer (Bitcoin or Lightning Network), RGB ensures that data is not visible to all, unlike a regular Bitcoin transaction.

This privacy ensures genuine decentralization and high resistance to censorship, making it highly useful for users seeking to protect their personal information or those exposed to censorship. After all, no one can attack something they are unaware of.

While RGB is extensible thanks to the schema, it also ensures the security of smart contracts by making their consensus independent. This limits the impact of a vulnerability on a specific smart contract.

Despite all these advantages, there is one potential drawback. The development flexibility offered by RGB could lead developers to create applications that combine multiple services in one place.

This centralization of services exposes users to weakening the protection of their private data. We could mitigate this effect by making RGB even more modular.

That means keeping each smart contract dedicated to a specific service rather than creating multi-functional contracts. This would better preserve data opacity and avoid exposure to a smart contract failure.

In summary, RGB goes beyond what Ethereum attempts to achieve with its shards by providing native privacy to Bitcoin.

To achieve similar privacy, Ethereum would need to rely on zero-knowledge rollups (ZK Rollups) second layers such as Starknet or zkSync.

In short, RGB is a true cryptographic product that shares the values of cypherpunks as it offers a certain layer of anonymity to its users.
Source : RGB FAQ