text stringlengths 0 1.08k |
|---|
} |
``` |
{% endcode %} |
**(1)** In this section: |
* `ffv` statement indicates the version of the contract. |
* `name` provides a human-readable identifier for the schema itself, although it provides no uniqueness guarantees |
**(2)** In this section `global_state` and its variables are declared, in particular: |
* The token's `GS_NOMINAL` set of specifications which according to the [Strict Type Library](https://docs.rgb.info/annexes/rgb-library-map#strict-types-and-strict-encoding) contain: the token full `name` , the `ticker`, some additional `details`, the digit `precision` of the asset. |
* `GS_TERMS` containing some additional contract `terms` such as a disclaimer. |
* `GS_ISSUED_SUPPLY` which defines the initial supply of the token. In this case, since no inflation is allowed, it also represents the max supply. |
* The `Once` statement guarantees that all these declarations are associated with a single value. |
**(3)** In `owned_type` section, through the `OS_ASSET` statement, we can find the **StateType declaration** of the fungible token being transferred through the owned state assignment. The quantity of token used in the transfer is declared as a [Fungible Type](https://docs.rgb.info/rgb-state-and-operations/components-o... |
**(4)** This section of the contract schema marks the beginning of **Contract Operations' declaration section.** Starting from the operation allowed within `genesis` : |
* No `metadata` are declared. |
* The instantiation, inside the Genesis state, of all the variables of the Global State variables previously defined in code section (2). |
* The declaration of the first `assignment(s)` of the token using the previously declared type `OS_ASSET`. Note that the `OnceOrMore` statement allows more than one allocation, in case the issuer wants to split the initial supply among multiple owners. |
**(5)** The `transitions` section provides the declaration of a single `TS_TRANSFER` operation which: |
* Contains no `metadata`. |
* Doesn't update the global state (it was defined only in Genesis). |
* Takes as `inputs` at **one or more** assignments of type `OS_ASSET`. |
* Allows to declare **one or more** `assignments` of type `OS_ASSET`. |
* Points to the `AluVM` script that should be **executed when validating** operations of this type. |
**(6)** A **default assignment type** is defined, to be used for example to pay an invoice that doesn't specify one. |
# Lightning Network compatibility |
When an RGB state transition is committed into a Bitcoin transaction, such transaction does not necessarily need to be settled on the blockchain immediately, as it can derive its security by being part of a [Lightning Network](https://docs.rgb.info/annexes/glossary#lightning-network) payment channel. In this way, every... |
The first thing needed for an RGB lightning channel to work is a funding transaction. The funding operation is composed of two parts: |
1. The bitcoin funding to create the multisig. |
2. The RGB asset funding sending assets to the multisig [UTXO](https://docs.rgb.info/annexes/glossary#utxo). |
The bitcoin funding is needed to create the channel UTXO where the assets can be allocated to, but it doesn’t necessarily need to have an economically significant amount of satoshis in it as long as it has enough balance that all the outputs of the lightning commitment transitions will be above the dust limit. |
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-a6351478281d27b01950b30728be1f2dca42d75a%2Fln-comp1.png?alt=media" alt=""><figcaption><p><strong>In this example Alice is opening a channel with Bob providing 10k satoshis an... |
Once the funding transaction has been prepared, but not yet signed and broadcast, it is time to prepare the commitment transactions that will allow both parties to unilaterally close the channel at any time. The structure of the commitment transactions are almost identical to those of normal lightning channels, with th... |
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-4c1016b4f679132487f958dd5aa4168c81814040%2Fimage.png?alt=media" alt=""><figcaption><p><strong>Commitment transaction signed by Alice and ready to be broadcasted by Bob, with ... |
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-036db95bb352cd5344b43e94a8794556e9c65659%2Fimage.png?alt=media" alt=""><figcaption><p><strong>Commitment transaction signed by Bob and ready to be broadcast by Alice, with as... |
As we can see in the example, the RGB state transition is moving the assets towards the allocation that corresponds to the output created by the lightning commitment transaction. This means that Alice, if Bob were to become irresponsive until the timelock expired, would be able to recover both satoshis and USDTs she lo... |
## Updating the channel |
When a payment occurs between the two parties and the state of the channel needs to be updated, a new pair of commitment transactions will be created. The bitcoin amounts in the output of the new commitment transaction are not relevant and may or may not stay the same as they were in a previous state (depending on the ... |
In the example below, 100 USDT have been moved from Alice to Bob, making the new state of the balances be 400 USDT to Alice and 100 USDT to Bob. |
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-4e20173360fffc153e7a0299f4205140537ad5cd%2Fln-comp4.png?alt=media" alt=""><figcaption><p><strong>Update to the commitment transaction, signed by Alice and ready to be broadca... |
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-825ce8e57ec104f4247e24972d217be4c984ae16%2Fln-comp5.png?alt=media" alt=""><figcaption><p><strong>Update to the commitment transaction, signed by Bob and ready to be broadcast... |
Notice that in the RGB state transition, while the UTXO endpoints where the assets get allocated change with every new lightning commitment transaction, the RGB input is always the original funding multisig where the assets are allocated on-chain until the channel closure. |
The RGB state transition moves the assets from the multisig where the funding happened, towards the outputs that are being created by the lightning commitment transaction. In this way, the RGB state transition inherits directly from the lightning commitment transaction all the security properties in case of unilateral ... |
This means that if Alice broadcasts an old state (trying to get back the 100 USDT she just sent), Bob will be able to spend the output using Alice’s revocation secret, and while spending the output he will not only move the satoshis towards an address under his exclusive control, but he will also be able to move the RG... |
## Introducing HTLCs |
Above we just saw a simplification of payment channels that involve only two parties, but since in reality the lightning network is designed also to route payments towards more participants, all payments actually use HTLCs output. With RGB channels it works exactly the same way, for each payment that is being routed th... |
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-1cab6bdeaa454dbce854c378e6527cbf57869e9c%2Fimage.png?alt=media" alt=""><figcaption><p><strong>HTLC transaction involving RGB state transition.</strong></p></figcaption></figu... |
The above example only contains one HTLC output, but more can be added as needed for all the pending routed payments, and for each new HTLC output there will be a new corresponding RGB allocation in the state transition. |
Every HTLC output needs a bitcoin amount above dust that ensures, in case the channel is force-closed while the payment is in flight, the legitimate owner will be able to spend it and claim the corresponding assets. This means that, in practice, every RGB payment on lightning also needs to transfer some satoshis as wel... |
# Glossary |
Terminology used in RGB sorted in alphabetical order |
### Anchor |
Set of client-side data that proves the inclusion of a unique [commitment](#commitment) inside a transaction. In RGB protocol it is constituted by: |
* The Bitcoin transaction ID of the [witness transaction](#witness-transaction). |
* The Multi Protocol Commitment - [MPC](#multi-protocol-commitment-mpc). |
* The Deterministic Bitcoin Commitment - [DBC](#deterministic-bitcoin-commitment-dbc). |
* The [ETP](#extra-transaction-proof-etp) in the case of [Tapret](https://docs.rgb.info/commitment-layer/deterministic-bitcoin-commitments-dbc/tapret) commitment scheme. |
### AluVM |
Acronym of Algorithmic logic unit Virtual Machine, it is a register-based virtual machine for smart contract validation and distributed computing, used but not limited to RGB contract validation. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.