RGB Docs
  • RGB Protocol Documentation
  • Distributed Computing Concepts
    • Paradigms of Distributed Computing
    • Client-side Validation
    • Single-use Seals and Proof of Publication
  • Commitment layer
    • Commitment Schemes within Bitcoin and RGB
    • Deterministic Bitcoin Commitments - DBC
      • Opret
      • Tapret
    • Multi Protocol Commitments - MPC
    • Anchors
  • RGB State and Operations
    • Introduction to Smart Contracts and their States
    • Contract Operations
    • Components of a Contract Operation
    • Features of RGB State
  • RGB Contract Implementation
    • Contract Implementation in RGB
    • Schema
      • Schema example: Non-Inflatable Assets
    • Interface
      • Standard Interfaces by LNP/BP Association
      • Interface example: RGB20
    • Interface Implementation
  • RGB over Lightning Network
    • Lightning Network compatibility
  • Annexes
    • Glossary
    • Contract Transfers
    • Invoices
    • RGB Library Map
Powered by GitBook
On this page
  1. RGB Contract Implementation

Contract Implementation in RGB

PreviousFeatures of RGB StateNextSchema

Last updated 8 months ago

We have finally arrived at describing how an RGB contract is actually defined and implemented. In addition to , which we have discussed , the definition of a in the RGB ecosystem is realized by two independent plus a third complementary one:

  • which represents the data file containing the fundamental contract declarations, possible states and operations constituting its .

  • which contains the instruction to parse the contract and to expose state data to users and wallet interface.

  • is a third complementary component that is responsible for bridging the previous two together.

In this regard, it is important to point out that each one of these components can be freely and independently developed by different parties, provided that they respect the RGB consensus rules. This represents a notable feature of the RGB ecosystem which allows an even higher degree of separation and decentralization among the building process of the different components of the contract itself.

In the picture below a general scheme of all the components together with a summary explanation is reported. In addition to this, the creation of a compiled Genesis with suitable procedures derived from the 3 components just described completes the issuance phase of a contract, which becomes then fully operational to users.

To give a better general view, the following table summarizes the main characteristics of each one and the equivalent terminology adopted both in Object Oriented Programming (OOP) languages and in Ethereum contract system.

Contract component
Meaning
OOP terms
Ethereum terms

Genesis

Initial Contract State

Class constructor

Contract constructor

Schema

Contract business logic

Class

Contract

Interface

Contract semantics

Interface (Java),

trait (Rust), protocol (Swift)

ERC* Standard

Interface Implementation

Mapping semantics to business logic

Impl (Rust), Implements (Java)

Application Binary Interface (ABI)

In the next sections, we shall explore in more depth the role and the technicalities of each one of these constructs.

It's worth pointing out that, in order to work with an RGB contract a wallet needs to import all the 4 compiled components (Schema, Interface, Interface Implementation, and Genesis) through a .

Schema
Interface
earlier
The list of components which defines a contract in RGB and their analogies with construct of OOP programming languages.
RGB contract anatomy
Genesis
contract
business logic
Interface Implementation
contract consignment